developer3000 commited on
Commit
84a2f6a
·
verified ·
1 Parent(s): 3f0455e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,6 +1,4 @@
1
- from langchain.chat_models import ChatOpenAI
2
- from langchain.schema import AIMessage, HumanMessage
3
- import openai
4
  from huggingface_hub import hf_hub_download
5
  from llama_cpp import Llama
6
  import gradio as gr
@@ -30,14 +28,13 @@ def my_inference_function(Question):
30
  #gradio_interface.launch()
31
 
32
  def predict(message, history):
33
- history_langchain_format = []
34
- for human, ai in history:
35
- history_langchain_format.append(HumanMessage(content=human))
36
- history_langchain_format.append(AIMessage(content=ai))
37
- history_langchain_format.append(HumanMessage(content=message))
38
- #gpt_response = llm(history_langchain_format)
39
- 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_langchain_format} Medical Answer:"
40
  gpt_response = llm(prompt, max_tokens=4000)['choices'][0]['text']
41
  return gpt_response.content
42
 
43
- gr.ChatInterface(predict).launch()
 
1
+ from openai import OpenAI
 
 
2
  from huggingface_hub import hf_hub_download
3
  from llama_cpp import Llama
4
  import gradio as gr
 
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
+ 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:"
 
37
  gpt_response = llm(prompt, max_tokens=4000)['choices'][0]['text']
38
  return gpt_response.content
39
 
40
+ gr.ChatInterface(predict).launch(share=True)