developer3000 commited on
Commit
5bdffed
·
verified ·
1 Parent(s): fa4804d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -26
app.py CHANGED
@@ -1,5 +1,3 @@
1
- from openai import OpenAI
2
- from huggingface_hub import hf_hub_download
3
  from llama_cpp import Llama
4
  import gradio as gr
5
  import os
@@ -20,29 +18,11 @@ def my_inference_function(Question):
20
  response = llm(prompt, max_tokens=4000)['choices'][0]['text']
21
  return response
22
 
23
- #gradio_interface = gr.Interface(
24
- # fn = my_inference_function,
25
- # inputs = "text",
26
- # outputs = "text"
27
- #)
28
- #gradio_interface.launch()
29
 
30
- def predict(message, history):
31
- history_openai_format = []
32
- for human, assistant in history:
33
- history_openai_format.append({"role": "user", "content": human })
34
- history_openai_format.append({"role": "assistant", "content":assistant})
35
- history_openai_format.append({"role": "user", "content": message})
36
-
37
- prompt = f"You are an expert and experienced from the healthcare and biomedical domain with extensive medical knowledge and practical experience. Your name is OpenBioLLM, and you were developed by Saama AI Labs with Open Life Science AI. who's willing to help answer the user's query with explanation. In your explanation, leverage your deep medical expertise such as relevant anatomical structures, physiological processes, diagnostic criteria, treatment guidelines, or other pertinent medical concepts. Use precise medical terminology while still aiming to make the explanation clear and accessible to a general audience. Medical Question: {history_openai_format} Medical Answer:"
38
- response = llm(prompt, max_tokens=4000)['choices'][0]['text']
39
 
40
- partial_message = ""
41
- for chunk in response:
42
- if chunk.choices[0].delta.content is not None:
43
- partial_message = partial_message + chunk.choices[0].delta.content
44
- yield partial_message
45
-
46
- # return gpt_response
47
-
48
- gr.ChatInterface(predict).launch()
 
 
 
1
  from llama_cpp import Llama
2
  import gradio as gr
3
  import os
 
18
  response = llm(prompt, max_tokens=4000)['choices'][0]['text']
19
  return response
20
 
21
+ gradio_interface = gr.Interface(
22
+ fn = my_inference_function,
23
+ inputs = "text",
24
+ outputs = "text"
25
+ )
 
26
 
27
+ gradio_interface.launch()
 
 
 
 
 
 
 
 
28