Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import openai
|
|
8 |
llm_api_options = ["OpenAI API","Azure OpenAI API","Google PaLM API", "Llama 2"]
|
9 |
TEST_MESSAGE = "My favorite TV shows are The Mentalist, The Blacklist, Designated Survivor, and Unforgettable. What are ten series that I should watch next?"
|
10 |
|
11 |
-
|
12 |
def test_handler(optionSelection, prompt: str = "Write an introductory paragraph to explain Generative AI to the reader of this content."):
|
13 |
if optionSelection not in llm_api_options:
|
14 |
raise ValueError("Invalid choice!")
|
@@ -34,12 +33,9 @@ def test_handler(optionSelection, prompt: str = "Write an introductory paragraph
|
|
34 |
model = model,
|
35 |
messages = messages,
|
36 |
temperature = 0.7
|
37 |
-
)
|
38 |
-
|
39 |
-
print(completion)
|
40 |
response = completion["choices"][0]["message"].content
|
41 |
-
|
42 |
-
return message, response
|
43 |
case "Azure OpenAI API":
|
44 |
return "", ""
|
45 |
case "Google PaLM API":
|
@@ -56,8 +52,12 @@ with gr.Blocks() as LLMDemoTabbedScreen:
|
|
56 |
test_string_output_info = gr.Label(value="Output Info", label="Info")
|
57 |
test_button = gr.Button("Try it")
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
if __name__ == "__main__":
|
63 |
LLMDemoTabbedScreen.launch()
|
|
|
8 |
llm_api_options = ["OpenAI API","Azure OpenAI API","Google PaLM API", "Llama 2"]
|
9 |
TEST_MESSAGE = "My favorite TV shows are The Mentalist, The Blacklist, Designated Survivor, and Unforgettable. What are ten series that I should watch next?"
|
10 |
|
|
|
11 |
def test_handler(optionSelection, prompt: str = "Write an introductory paragraph to explain Generative AI to the reader of this content."):
|
12 |
if optionSelection not in llm_api_options:
|
13 |
raise ValueError("Invalid choice!")
|
|
|
33 |
model = model,
|
34 |
messages = messages,
|
35 |
temperature = 0.7
|
36 |
+
)
|
|
|
|
|
37 |
response = completion["choices"][0]["message"].content
|
38 |
+
return completion, response
|
|
|
39 |
case "Azure OpenAI API":
|
40 |
return "", ""
|
41 |
case "Google PaLM API":
|
|
|
52 |
test_string_output_info = gr.Label(value="Output Info", label="Info")
|
53 |
test_button = gr.Button("Try it")
|
54 |
|
55 |
+
|
56 |
+
test_button.click(
|
57 |
+
fn=test.test_handler,
|
58 |
+
inputs=[llm_api_options, test_string],
|
59 |
+
outputs=[test_string_output_info, test_string_response]
|
60 |
+
)
|
61 |
|
|
|
|
|
62 |
if __name__ == "__main__":
|
63 |
LLMDemoTabbedScreen.launch()
|