8000 Merge pull request #8 from ContextLab/main · ContextLab/chatify-server@a81ecea · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request KordingLab#8 from ContextLab/main
Browse files Browse the repository at this point in the history
avoid dialogue format
  • Loading branch information
jeremymanning authored Aug 4, 2023
2 parents 41b80a1 + 7c0a57d commit a81ecea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions chatify_server/response_providers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional, Protocol
from langchain.chat_models import ChatOpenAI
from langchain import PromptTemplate, LLMChain
from langchain import LLMChain
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate

from ..models import Prompt
from ..config import OpenAIConfig
Expand Down Expand Up @@ -54,11 +55,11 @@ async def get_response(self, prompt: Prompt, content: str) -> str:
If the user seems to be providing a plain text request rather than Python code, you should ask them to provide Python code instead and re-send their request.
Above all, try to be as helpful as possible by following the instructions above and using your extensive domain knowledge. If you do not know something, do not make something up. Instead, simply say that you do not know or that you are unsure.
"""

system_prompt = SystemMessagePromptTemplate.from_template(prompt.system_prompt + '\n' + addendum)
user_prompt = HumanMessagePromptTemplate.from_template(prompt.prompt_text, input_variables=['text'])

prompt_text = prompt.prompt_text

px = PromptTemplate(template=f'SYSTEM: {system_prompt}\n{addendum}\n{prompt_text}',
input_variables=['text'])
px = ChatPromptTemplate.from_messages([system_prompt, user_prompt])

chain = LLMChain(prompt=px, llm=llm)
return chain.run(content).strip()
Expand Down
Loading

0 comments on commit a81ecea

Please sign in to comment.
0