Spaces:
Runtime error
Runtime error
Nullzero
commited on
Commit
·
f2b2988
1
Parent(s):
69a0c76
updated app
Browse files
app.py
CHANGED
|
@@ -18,19 +18,19 @@ from langchain.chains import SimpleSequentialChain
|
|
| 18 |
|
| 19 |
def load_chain(api_key):
|
| 20 |
os.environ["OPENAI_API_KEY"] = api_key
|
| 21 |
-
llm = OpenAI(temperature=0.
|
| 22 |
#user_in = input("Please describe your Python project in one to two sentences: ")
|
| 23 |
|
| 24 |
first_prompt = PromptTemplate(
|
| 25 |
input_variables=["user_in"],
|
| 26 |
-
template= "
|
| 27 |
)
|
| 28 |
#First chain
|
| 29 |
chain = LLMChain(llm=llm, prompt=first_prompt)
|
| 30 |
|
| 31 |
second_prompt = PromptTemplate(
|
| 32 |
-
input_variables=["
|
| 33 |
-
template=
|
| 34 |
)
|
| 35 |
|
| 36 |
chain_two = LLMChain(llm=llm, prompt=second_prompt)
|
|
@@ -58,7 +58,7 @@ if "past" not in st.session_state:
|
|
| 58 |
|
| 59 |
|
| 60 |
def get_text():
|
| 61 |
-
user_input = st.text_input("Please describe your desired python
|
| 62 |
return user_input
|
| 63 |
|
| 64 |
|
|
@@ -69,11 +69,11 @@ if user_input:
|
|
| 69 |
chain = load_chain(openai_api_key)
|
| 70 |
output = chain.run(input=user_input)
|
| 71 |
|
| 72 |
-
|
| 73 |
st.session_state.generated.append(output)
|
| 74 |
|
| 75 |
if st.session_state["generated"]:
|
| 76 |
|
| 77 |
for i in range(len(st.session_state["generated"]) - 1, -1, -1):
|
| 78 |
message(st.session_state["generated"][i], key=str(i))
|
| 79 |
-
|
|
|
|
| 18 |
|
| 19 |
def load_chain(api_key):
|
| 20 |
os.environ["OPENAI_API_KEY"] = api_key
|
| 21 |
+
llm = OpenAI(model_name="gpt-3.5-turbo", temperature=0.1)
|
| 22 |
#user_in = input("Please describe your Python project in one to two sentences: ")
|
| 23 |
|
| 24 |
first_prompt = PromptTemplate(
|
| 25 |
input_variables=["user_in"],
|
| 26 |
+
template= "Write the outline of the coding steps to develop the program {user_in} in five steps. Use Python3 and Be concise. \n\n"
|
| 27 |
)
|
| 28 |
#First chain
|
| 29 |
chain = LLMChain(llm=llm, prompt=first_prompt)
|
| 30 |
|
| 31 |
second_prompt = PromptTemplate(
|
| 32 |
+
input_variables=["program"],
|
| 33 |
+
template= '''Produce the python3 code for each step of the {program} described. Use python3 style. Be concise in the code and opinionated about framework choice.'''
|
| 34 |
)
|
| 35 |
|
| 36 |
chain_two = LLMChain(llm=llm, prompt=second_prompt)
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
def get_text():
|
| 61 |
+
user_input = st.text_input("Please describe your desired python project in 1-2 sentences. The output will be five steps including code.", key="input")
|
| 62 |
return user_input
|
| 63 |
|
| 64 |
|
|
|
|
| 69 |
chain = load_chain(openai_api_key)
|
| 70 |
output = chain.run(input=user_input)
|
| 71 |
|
| 72 |
+
st.session_state.past.append(user_input)
|
| 73 |
st.session_state.generated.append(output)
|
| 74 |
|
| 75 |
if st.session_state["generated"]:
|
| 76 |
|
| 77 |
for i in range(len(st.session_state["generated"]) - 1, -1, -1):
|
| 78 |
message(st.session_state["generated"][i], key=str(i))
|
| 79 |
+
message(st.session_state["past"][i], is_user=True, key=str(i) + "_user")
|