Skip to content

Commit d01d7e8

Browse files
author
melihunsal
committed
code reformatted
1 parent 880dc9d commit d01d7e8

22 files changed

+195
-200
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "demogpt"
7-
version = "1.1.2.4"
7+
version = "1.1.2.1"
88
description = "Auto Gen-AI App Generator with the Power of Llama 2"
99
authors = ["Melih Unsal <melih@demogpt.io>"]
1010
license = "MIT"

src/alpha/chains/chains.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,28 @@ def buttonText(cls, instruction):
8484
return cls.getChain(
8585
human_template=prompts.button_text.human_template, instruction=instruction
8686
)
87-
87+
8888
@classmethod
8989
def helpers(cls, instruction):
9090
system_inputs = Chains.inputs(instruction)
9191
button_text = Chains.buttonText(instruction)
92-
return system_inputs, button_text
93-
92+
return system_inputs, button_text
93+
9494
@classmethod
9595
def plan(cls, instruction):
9696
return cls.getChain(
97-
system_template = prompts.plan.system_template,
97+
system_template=prompts.plan.system_template,
9898
human_template=prompts.plan.human_template,
99-
instruction=instruction
99+
instruction=instruction,
100100
)
101-
101+
102102
@classmethod
103-
def draft(cls, instruction,plan):
103+
def draft(cls, instruction, plan):
104104
return cls.getChain(
105105
system_template=prompts.draft.system_template,
106106
human_template=prompts.draft.human_template,
107107
instruction=instruction,
108-
plan=plan
108+
plan=plan,
109109
)
110110

111111
@classmethod

src/alpha/chains/prompts/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from . import (button_text, code, explain, final,
2-
streamlit, system_inputs,tasks, plan,
3-
draft)
1+
from . import (button_text, code, draft, explain, final, plan, streamlit,
2+
system_inputs, tasks)

src/alpha/chains/prompts/draft.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
system_template = """
42
Create a code for the instruction using the plan
53
There are 3 available functions which are "prompt", "input" and "show".
@@ -152,4 +150,4 @@ def validateAnswer(question, user_answer, answer):
152150
Plan:
153151
{plan}
154152
Code:
155-
"""
153+
"""

src/alpha/chains/prompts/plan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
Instruction: {instruction}
4242
Let’s think step by step.
4343
44-
"""
44+
"""

src/plan/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
logging.error("dotenv import error but no needed")
1919

2020

21-
def generate_response(txt,title):
21+
def generate_response(txt, title):
2222
"""
2323
Generate response using the LangChainCoder.
2424
@@ -28,7 +28,7 @@ def generate_response(txt,title):
2828
Yields:
2929
dict: A dictionary containing response information.
3030
"""
31-
for data in agent(txt,title):
31+
for data in agent(txt, title):
3232
yield data
3333

3434

@@ -47,14 +47,14 @@ def generate_response(txt,title):
4747
)
4848

4949
models = (
50-
"gpt-3.5-turbo",
50+
"gpt-3.5-turbo",
5151
"gpt-3.5-turbo-0301",
5252
"gpt-3.5-turbo-0613",
5353
"gpt-3.5-turbo-16k",
5454
"gpt-3.5-turbo-16k-0613",
5555
"gpt-4",
5656
"gpt-4-0314",
57-
"gpt-4-0613"
57+
"gpt-4-0613",
5858
)
5959

6060
model_name = st.sidebar.selectbox("Model", models)
@@ -101,7 +101,7 @@ def progressBar(percentage, bar=None):
101101
st.session_state["pid"] = -1
102102

103103
code_empty = st.empty()
104-
for data in generate_response(demo_idea,demo_title):
104+
for data in generate_response(demo_idea, demo_title):
105105
done = data["done"]
106106
message = data["message"]
107107
stage = data["stage"]

src/plan/chains/chains.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
2+
import os
23

34
import chains.prompts as prompts
45
import utils
5-
import os
66

77
from langchain import LLMChain
88
from langchain.chat_models import ChatOpenAI
@@ -13,7 +13,9 @@
1313

1414
class Chains:
1515
@classmethod
16-
def setLlm(cls, model, openai_api_key=os.getenv("OPENAI_API_KEY",""), temperature=0):
16+
def setLlm(
17+
cls, model, openai_api_key=os.getenv("OPENAI_API_KEY", ""), temperature=0
18+
):
1719
Chains.llm = ChatOpenAI(
1820
model=model, openai_api_key=openai_api_key, temperature=temperature
1921
)
@@ -27,13 +29,13 @@ def getChain(cls, system_template="", human_template="", **kwargs):
2729
prompts.append(HumanMessagePromptTemplate.from_template(human_template))
2830
chat_prompt = ChatPromptTemplate.from_messages(prompts)
2931
return LLMChain(llm=cls.llm, prompt=chat_prompt).run(**kwargs)
30-
32+
3133
@classmethod
3234
def plan(cls, instruction):
3335
return cls.getChain(
34-
system_template = prompts.plan.system_template,
36+
system_template=prompts.plan.system_template,
3537
human_template=prompts.plan.human_template,
36-
instruction=instruction
38+
instruction=instruction,
3739
)
3840

3941
@classmethod
@@ -42,16 +44,17 @@ def tasks(cls, instruction, plan):
4244
system_template=prompts.tasks.system_template,
4345
human_template=prompts.tasks.human_template,
4446
instruction=instruction,
45-
plan=plan
47+
plan=plan,
4648
)
4749
return json.loads(task_list)
4850

4951
@classmethod
50-
def final(cls, instruction, code_snippets,plan):
52+
def final(cls, instruction, code_snippets, plan):
5153
code = cls.getChain(
5254
system_template=prompts.final.system_template,
53-
human_template=prompts.final.human_template,
55+
human_template=prompts.final.human_template,
5456
instruction=instruction,
5557
code_snippets=code_snippets,
56-
plan=plan)
58+
plan=plan,
59+
)
5760
return utils.refine(code)

src/plan/chains/prompts/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
from . import (tasks, plan, final)
2-
from .task_list import (ui_input_text, ui_output_text, prompt_chat_template,ui_input_file)
1+
from . import final, plan, tasks
2+
from .task_list import (prompt_chat_template, ui_input_file, ui_input_text,
3+
ui_output_text)

src/plan/chains/prompts/draft.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
system_template = """
42
Create a code for the instruction using the plan
53
There are 3 available functions which are "prompt", "input" and "show".
@@ -152,4 +150,4 @@ def validateAnswer(question, user_answer, answer):
152150
Plan:
153151
{plan}
154152
Code:
155-
"""
153+
"""

src/plan/chains/prompts/final.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
Draft Code: {code_snippets}
1818
################################
1919
Refined Code:
20-
"""
20+
"""

src/plan/chains/prompts/plan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
Instruction: {instruction}
5353
Let’s think step by step.
5454
55-
"""
55+
"""
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from . import (ui_input_text,ui_output_text,prompt_chat_template,ui_input_file)
1+
from . import (prompt_chat_template, ui_input_file, ui_input_text,
2+
ui_output_text)

src/plan/chains/prompts/task_list/ui_input_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
88
Instruction:{instruction}
99
Streamlit Code:
10-
"""
10+
"""

src/plan/chains/prompts/task_list/ui_input_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
77
Instruction:{instruction}
88
Streamlit Code:
9-
"""
9+
"""

src/plan/chains/prompts/task_list/ui_output_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
1414
Instruction:{instruction}
1515
Streamlit Code:
16-
"""
16+
"""

src/plan/chains/prompts/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
Plan : {plan}
3434
##########################
3535
List of Task Objects (Python List of JSON), and ensure that each task corresponds to each step in the plan:
36-
"""
36+
"""

src/plan/chains/task_chains.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
2+
import os
23

34
import chains.prompts as prompts
45
import utils
5-
import os
66

77
from langchain import LLMChain
88
from langchain.chat_models import ChatOpenAI
@@ -13,8 +13,11 @@
1313

1414
class TaskChains:
1515
llm = None
16+
1617
@classmethod
17-
def setLlm(cls, model, openai_api_key=os.getenv("OPENAI_API_KEY",""), temperature=0):
18+
def setLlm(
19+
cls, model, openai_api_key=os.getenv("OPENAI_API_KEY", ""), temperature=0
20+
):
1821
cls.llm = ChatOpenAI(
1922
model=model, openai_api_key=openai_api_key, temperature=temperature
2023
)
@@ -32,11 +35,11 @@ def getChain(cls, system_template="", human_template="", **kwargs):
3235
@classmethod
3336
def uiInputText(cls, task):
3437
variable = task["output_key"]
35-
instruction = task["description"]
38+
instruction = task["description"]
3639
code = cls.getChain(
3740
human_template=prompts.ui_input_text.human_template,
3841
instruction=instruction,
39-
variable=variable
42+
variable=variable,
4043
)
4144
return utils.refine(code)
4245

@@ -45,35 +48,34 @@ def uiOutputText(cls, task):
4548
args = task["input_key"]
4649
if isinstance(args, list):
4750
args = ",".join(args)
48-
instruction = task["description"]
51+
instruction = task["description"]
4952
code = cls.getChain(
5053
human_template=prompts.ui_output_text.human_template,
5154
instruction=instruction,
52-
args=args
55+
args=args,
5356
)
5457
return utils.refine(code)
55-
58+
5659
@classmethod
5760
def uiInputFile(cls, task):
5861
variable = task["output_key"]
59-
instruction = task["description"]
62+
instruction = task["description"]
6063
code = cls.getChain(
6164
human_template=prompts.ui_input_file.human_template,
6265
instruction=instruction,
63-
variable=variable
66+
variable=variable,
6467
)
6568
return utils.refine(code)
6669

67-
6870
@classmethod
6971
def promptChatTemplate(cls, task):
7072
inputs = task["input_key"]
71-
instruction = task["description"]
73+
instruction = task["description"]
7274

7375
code = cls.getChain(
7476
system_template=prompts.prompt_chat_template.system_template,
7577
human_template=prompts.prompt_chat_template.human_template,
7678
instruction=instruction,
77-
inputs=inputs
79+
inputs=inputs,
7880
)
7981
return utils.refine(code)

0 commit comments

Comments
 (0)