Skip to content

Commit

Permalink
code reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
melihunsal committed Aug 4, 2023
1 parent 880dc9d commit d01d7e8
Show file tree
Hide file tree
Showing 22 changed files with 195 additions and 200 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "demogpt"
version = "1.1.2.4"
version = "1.1.2.1"
description = "Auto Gen-AI App Generator with the Power of Llama 2"
authors = ["Melih Unsal <melih@demogpt.io>"]
license = "MIT"
Expand Down
16 changes: 8 additions & 8 deletions src/alpha/chains/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,28 @@ def buttonText(cls, instruction):
return cls.getChain(
human_template=prompts.button_text.human_template, instruction=instruction
)

@classmethod
def helpers(cls, instruction):
system_inputs = Chains.inputs(instruction)
button_text = Chains.buttonText(instruction)
return system_inputs, button_text
return system_inputs, button_text

@classmethod
def plan(cls, instruction):
return cls.getChain(
system_template = prompts.plan.system_template,
system_template=prompts.plan.system_template,
human_template=prompts.plan.human_template,
instruction=instruction
instruction=instruction,
)

@classmethod
def draft(cls, instruction,plan):
def draft(cls, instruction, plan):
return cls.getChain(
system_template=prompts.draft.system_template,
human_template=prompts.draft.human_template,
instruction=instruction,
plan=plan
plan=plan,
)

@classmethod
Expand Down
5 changes: 2 additions & 3 deletions src/alpha/chains/prompts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import (button_text, code, explain, final,
streamlit, system_inputs,tasks, plan,
draft)
from . import (button_text, code, draft, explain, final, plan, streamlit,
system_inputs, tasks)
4 changes: 1 addition & 3 deletions src/alpha/chains/prompts/draft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


system_template = """
Create a code for the instruction using the plan
There are 3 available functions which are "prompt", "input" and "show".
Expand Down Expand Up @@ -152,4 +150,4 @@ def validateAnswer(question, user_answer, answer):
Plan:
{plan}
Code:
"""
"""
2 changes: 1 addition & 1 deletion src/alpha/chains/prompts/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
Instruction: {instruction}
Let’s think step by step.
"""
"""
10 changes: 5 additions & 5 deletions src/plan/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
logging.error("dotenv import error but no needed")


def generate_response(txt,title):
def generate_response(txt, title):
"""
Generate response using the LangChainCoder.
Expand All @@ -28,7 +28,7 @@ def generate_response(txt,title):
Yields:
dict: A dictionary containing response information.
"""
for data in agent(txt,title):
for data in agent(txt, title):
yield data


Expand All @@ -47,14 +47,14 @@ def generate_response(txt,title):
)

models = (
"gpt-3.5-turbo",
"gpt-3.5-turbo",
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-16k-0613",
"gpt-4",
"gpt-4-0314",
"gpt-4-0613"
"gpt-4-0613",
)

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

code_empty = st.empty()
for data in generate_response(demo_idea,demo_title):
for data in generate_response(demo_idea, demo_title):
done = data["done"]
message = data["message"]
stage = data["stage"]
Expand Down
21 changes: 12 additions & 9 deletions src/plan/chains/chains.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import os

import chains.prompts as prompts
import utils
import os

from langchain import LLMChain
from langchain.chat_models import ChatOpenAI
Expand All @@ -13,7 +13,9 @@

class Chains:
@classmethod
def setLlm(cls, model, openai_api_key=os.getenv("OPENAI_API_KEY",""), temperature=0):
def setLlm(
cls, model, openai_api_key=os.getenv("OPENAI_API_KEY", ""), temperature=0
):
Chains.llm = ChatOpenAI(
model=model, openai_api_key=openai_api_key, temperature=temperature
)
Expand All @@ -27,13 +29,13 @@ def getChain(cls, system_template="", human_template="", **kwargs):
prompts.append(HumanMessagePromptTemplate.from_template(human_template))
chat_prompt = ChatPromptTemplate.from_messages(prompts)
return LLMChain(llm=cls.llm, prompt=chat_prompt).run(**kwargs)

@classmethod
def plan(cls, instruction):
return cls.getChain(
system_template = prompts.plan.system_template,
system_template=prompts.plan.system_template,
human_template=prompts.plan.human_template,
instruction=instruction
instruction=instruction,
)

@classmethod
Expand All @@ -42,16 +44,17 @@ def tasks(cls, instruction, plan):
system_template=prompts.tasks.system_template,
human_template=prompts.tasks.human_template,
instruction=instruction,
plan=plan
plan=plan,
)
return json.loads(task_list)

@classmethod
def final(cls, instruction, code_snippets,plan):
def final(cls, instruction, code_snippets, plan):
code = cls.getChain(
system_template=prompts.final.system_template,
human_template=prompts.final.human_template,
human_template=prompts.final.human_template,
instruction=instruction,
code_snippets=code_snippets,
plan=plan)
plan=plan,
)
return utils.refine(code)
5 changes: 3 additions & 2 deletions src/plan/chains/prompts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import (tasks, plan, final)
from .task_list import (ui_input_text, ui_output_text, prompt_chat_template,ui_input_file)
from . import final, plan, tasks
from .task_list import (prompt_chat_template, ui_input_file, ui_input_text,
ui_output_text)
4 changes: 1 addition & 3 deletions src/plan/chains/prompts/draft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


system_template = """
Create a code for the instruction using the plan
There are 3 available functions which are "prompt", "input" and "show".
Expand Down Expand Up @@ -152,4 +150,4 @@ def validateAnswer(question, user_answer, answer):
Plan:
{plan}
Code:
"""
"""
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/final.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
Draft Code: {code_snippets}
################################
Refined Code:
"""
"""
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
Instruction: {instruction}
Let’s think step by step.
"""
"""
3 changes: 2 additions & 1 deletion src/plan/chains/prompts/task_list/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import (ui_input_text,ui_output_text,prompt_chat_template,ui_input_file)
from . import (prompt_chat_template, ui_input_file, ui_input_text,
ui_output_text)
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/task_list/ui_input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Instruction:{instruction}
Streamlit Code:
"""
"""
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/task_list/ui_input_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
Instruction:{instruction}
Streamlit Code:
"""
"""
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/task_list/ui_output_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
Instruction:{instruction}
Streamlit Code:
"""
"""
2 changes: 1 addition & 1 deletion src/plan/chains/prompts/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
Plan : {plan}
##########################
List of Task Objects (Python List of JSON), and ensure that each task corresponds to each step in the plan:
"""
"""
26 changes: 14 additions & 12 deletions src/plan/chains/task_chains.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import os

import chains.prompts as prompts
import utils
import os

from langchain import LLMChain
from langchain.chat_models import ChatOpenAI
Expand All @@ -13,8 +13,11 @@

class TaskChains:
llm = None

@classmethod
def setLlm(cls, model, openai_api_key=os.getenv("OPENAI_API_KEY",""), temperature=0):
def setLlm(
cls, model, openai_api_key=os.getenv("OPENAI_API_KEY", ""), temperature=0
):
cls.llm = ChatOpenAI(
model=model, openai_api_key=openai_api_key, temperature=temperature
)
Expand All @@ -32,11 +35,11 @@ def getChain(cls, system_template="", human_template="", **kwargs):
@classmethod
def uiInputText(cls, task):
variable = task["output_key"]
instruction = task["description"]
instruction = task["description"]
code = cls.getChain(
human_template=prompts.ui_input_text.human_template,
instruction=instruction,
variable=variable
variable=variable,
)
return utils.refine(code)

Expand All @@ -45,35 +48,34 @@ def uiOutputText(cls, task):
args = task["input_key"]
if isinstance(args, list):
args = ",".join(args)
instruction = task["description"]
instruction = task["description"]
code = cls.getChain(
human_template=prompts.ui_output_text.human_template,
instruction=instruction,
args=args
args=args,
)
return utils.refine(code)

@classmethod
def uiInputFile(cls, task):
variable = task["output_key"]
instruction = task["description"]
instruction = task["description"]
code = cls.getChain(
human_template=prompts.ui_input_file.human_template,
instruction=instruction,
variable=variable
variable=variable,
)
return utils.refine(code)


@classmethod
def promptChatTemplate(cls, task):
inputs = task["input_key"]
instruction = task["description"]
instruction = task["description"]

code = cls.getChain(
system_template=prompts.prompt_chat_template.system_template,
human_template=prompts.prompt_chat_template.human_template,
instruction=instruction,
inputs=inputs
inputs=inputs,
)
return utils.refine(code)
Loading

0 comments on commit d01d7e8

Please sign in to comment.