Spaces:
Runtime error
Runtime error
import gradio as gr | |
import openai | |
import os | |
llm_model = 'gpt-3.5-turbo-0125' | |
openai.api_key = os.environ['OPENAI_API_KEY'] | |
def get_completion(prompt, model=llm_model): | |
messages = [{"role": "user", "content": prompt}] | |
response = openai.ChatCompletion.create( | |
model=model, | |
messages=messages, | |
temperature=0, | |
) | |
return response.choices[0].message["content"] | |
def find_orgs(sentence): | |
prompt = f""" | |
Find all organizations in the text delimited by triple backticks. | |
text: | |
``` | |
{sentence} | |
``` | |
You should always start your answer with "Organizations are: " | |
""" | |
return get_completion(prompt) | |
iface = gr.Interface(fn=find_orgs, inputs="text", outputs="text") | |
iface.launch(share=True) |