forked from run-llama/llama-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llama_agi] Lint + Typing (run-llama#5)
- Loading branch information
1 parent
d234c86
commit 2cd8225
Showing
6 changed files
with
131 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,38 @@ | ||
from langchain.chains import LLMChain | ||
from langchain.llms import OpenAI | ||
from langchain.llms import OpenAI, BaseLLM | ||
from langchain.chat_models.base import BaseChatModel | ||
from langchain.chat_models import ChatOpenAI | ||
from langchain.prompts import PromptTemplate | ||
from typing import Optional, Union | ||
|
||
from agi.task_prompts import LC_EXECUTION_PROMPT | ||
|
||
|
||
class SimpleExecutionAgent: | ||
def __init__(self, llm=None, model_name="text-davinci-003"): | ||
if llm: | ||
def __init__( | ||
self, | ||
llm: Optional[Union[BaseLLM, BaseChatModel]] = None, | ||
model_name: str = "text-davinci-003", | ||
) -> None: | ||
if llm is not None: | ||
self._llm = llm | ||
elif model_name == "text-davinci-003": | ||
self._llm = OpenAI(temperature=0, model_name=model_name, max_tokens=512) | ||
else: | ||
self._llm = ChatOpenAI(temperature=0, model_name=model_name, max_tokens=512 ) | ||
self._llm = ChatOpenAI(temperature=0, model_name=model_name, max_tokens=512) | ||
|
||
self._prompt_template = PromptTemplate( | ||
template=LC_EXECUTION_PROMPT, | ||
input_variables=["task", "objective", "completed_tasks_summary"] | ||
template=LC_EXECUTION_PROMPT, | ||
input_variables=["task", "objective", "completed_tasks_summary"], | ||
) | ||
self._execution_chain = LLMChain(llm=self._llm, prompt=self._prompt_template) | ||
|
||
def execute_task(self, objective, task, completed_tasks_summary): | ||
|
||
def execute_task( | ||
self, objective: str, task: str, completed_tasks_summary: str | ||
) -> str: | ||
result = self._execution_chain.predict( | ||
objective=objective, | ||
task=task, | ||
completed_tasks_summary=completed_tasks_summary | ||
objective=objective, | ||
task=task, | ||
completed_tasks_summary=completed_tasks_summary, | ||
) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
langchain==0.0.141 | ||
llama-index==0.5.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters