Spaces:
Runtime error
Runtime error
Merge branch 'main' of https://huggingface.co/spaces/TeamTonic/MultiMed
Browse files229 unmodified lines2302312322332342359 unmodified lines245246247248249250251252253254255256229 unmodified linesreturn "No data found in the response."# Main function to handle the Gradio interface logicdef process_and_query(text=None):try:9 unmodified lines# text = "the user asks the following to his health adviser " + text# Now, use the text (either provided by the user or obtained from OpenAI) to query Vectaravectara_response_json = query_vectara(text)markdown_output = convert_to_markdown(vectara_response_json)client = OpenAI()prompt ="Answer in the same language, write it better,remove the sources, more understandable and make it 2 line answer:"markdown_output_final = markdown_outputcompletion = client.chat.completions.create(model="gpt-3.5-turbo",229 unmodified lines2302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602619 unmodified lines271272273274275276277278279280281282283284285286287288289290229 unmodified linesreturn "No data found in the response."# Main function to handle the Gradio interface logicdef process_summary_with_openai(summary):"""This function takes a summary text as input and processes it with OpenAI's GPT model."""try:# Ensure that the OpenAI client is properly initializedclient = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))# Create the prompt for OpenAI's completionprompt = "You are clinical consultant discussion training cases with students at TonicUniversity. You will recieve a summary assessment. Assess and describe the proper options in minute detail. Propose a course of action based on your assessment. Exclude any other commentary:"# Call the OpenAI API with the prompt and the summarycompletion = client.chat.completions.create(model="gpt-4-1106-preview", # Make sure to use the correct model namemessages=[{"role": "system", "content": prompt},{"role": "user", "content": summary}])# Extract the content from the completionfinal_summary = completion.choices[0].message.contentreturn final_summaryexcept Exception as e:return str(e)def process_and_query(text=None):try:9 unmodified lines# text = "the user asks the following to his health adviser " + text# Use the text to query Vectaravectara_response_json = query_vectara(text)# Convert the Vectara response to Markdownmarkdown_output = convert_to_markdown(vectara_response_json)# Process the summary with OpenAIfinal_response = process_summary_with_openai(markdown_output)# Return the processed summary along with the full outputreturn f"**Summary**: {final_response}\n\n**Full output**:\n{markdown_output}"except Exception as e:return str(e)completion = client.chat.completions.create(model="gpt-3.5-turbo",
app.py+38-4