Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain.llms import OpenAI
|
3 |
+
from langchain import PromptTemplate, LLMChain
|
4 |
+
|
5 |
+
def llm_setup():
|
6 |
+
|
7 |
+
llm = OpenAI(temperature=0.7, openai_api_key = st.secrets["OPENAI_API_KEY"])
|
8 |
+
|
9 |
+
template = """ Convert the following sentence to pirate english:
|
10 |
+
{input_text}
|
11 |
+
"""
|
12 |
+
|
13 |
+
prompt_template = PromptTemplate(input_variables = ["input_text"], template = template)
|
14 |
+
|
15 |
+
llm_chain = LLMChain(prompt=prompt_template, llm=llm)
|
16 |
+
|
17 |
+
return llm_chain
|
18 |
+
|
19 |
+
def generate_questions():
|
20 |
+
llm_chain = llm_setup()
|
21 |
+
st.session_state.output_text = llm_chain.run(st.session_state.input_text)
|
22 |
+
|
23 |
+
st.write("Sitafal Test Generator")
|
24 |
+
|
25 |
+
input_text = st.text_area('Give topic deatils', key="input_text")
|
26 |
+
|
27 |
+
generate_button = st.button("Generate", key="generate_button", on_click = generate_questions)
|
28 |
+
|
29 |
+
output_text = st.text_area("Generated questions", key = "output_text")
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|