CoolFace
Apppublic

richterts/Flow_GPT

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
0likes
app.py39 linesDownload Raw Back to root
1import gradio as gr2import openai3import os4import langchain5from langchain.chat_models import ChatOpenAI6from langchain.schema import AIMessage, HumanMessage7#import config8 9#openai.api_key = config.OPENAI_API_KEY10#openai.api_key = OPENAI_API_KEY11openai.api_key = os.environ["OPENAI_API_KEY"]12 13#news_api_key = os.environ["NEWS_API_KEY"]14 15#message_history = [{"role": "user", "content": f"You are Genius doctor, who is trying to determine and provide accurate diagnosis, ask questions to identify symptoms, clinic history, life style, psychosocial factors, allergies, or any recent events that could have negative impact or that could be the root cause of illness. Ask any other questions that you consider you need to know in order to came up with an accurate diagnosis and guide the patient for the next steps in terms of best physician or specialist that he/she should visit. At the end emphazise that you need to contact your personal doctor"},16#                   {"role": "assistant", "content": f"OK"}]17 18#message_history = [{"role": "user", "content": f"You are Genius materiality specialist, give suggestions and current trends with examples and ask any other questions that you consider you need to know in order to came up with an suggestion in terms of product lifecycle analysis"},19#                   {"role": "assistant", "content": f"OK"}]20 21message = [{"role": "user", "content": f"Act as a Genius doctor, at first introduce yourself as an AI Doctor and proceed to collect basic information to create patient profile,ask any set of questions that you consider you need to know in order to came up with an accurate diagnosis, once you have the diagnosis share information and provide the Spanish triage system (SET) category based on the diagnosis and guide the patient for the next steps in terms of best physician or specialist that he/she should visit. At the end emphazise that you need to contact your personal doctor"},22                   {"role": "assistant", "content": f"OK"}]23 24 25llm = ChatOpenAI(temperature=1.0, model='gpt-3.5-turbo-0613', openai_api_key=openai.api_key)26 27def predict(message, history):28    history_langchain_format = []29    for human, ai in history:30        history_langchain_format.append(HumanMessage(content=human))31        history_langchain_format.append(AIMessage(content=ai))32    history_langchain_format.append(HumanMessage(content=message))33    gpt_response = llm(history_langchain_format)34    return gpt_response.content35 36 37gr.ChatInterface(predict).launch()38  39