-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Agenta-AI/optional_params
Optional parameters now can be added in the code | Code can now be also run with cli without any change
- Loading branch information
Showing
8 changed files
with
105 additions
and
97 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
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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
from agenta import post | ||
from agenta import post, TextParam, FloatParam | ||
from dotenv import load_dotenv | ||
from langchain.chains import LLMChain | ||
from langchain.llms import OpenAI | ||
from langchain.prompts import PromptTemplate | ||
|
||
default_prompt = "What is a good name for a company that makes {product}?" | ||
|
||
|
||
@post | ||
def completion(product: str) -> str: | ||
llm = OpenAI(temperature=0.9) | ||
def completion(product: str, temperature: FloatParam = 0.9, prompt_template: TextParam = default_prompt) -> str: | ||
llm = OpenAI(temperature=temperature) | ||
prompt = PromptTemplate( | ||
input_variables=["product"], | ||
template="What is a good name for a company that makes {product}?", | ||
template=prompt_template, | ||
) | ||
chain = LLMChain(llm=llm, prompt=prompt) | ||
output = chain.run(product=product) | ||
return output | ||
|
||
|
||
if __name__ == "__main__": | ||
load_dotenv() | ||
print(completion("socks")) | ||
return output |
This file was deleted.
Oops, something went wrong.
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,26 +1,24 @@ | ||
from agenta import post | ||
from agenta import post, TextParam, FloatParam | ||
from dotenv import load_dotenv | ||
from langchain.chains import LLMChain | ||
from langchain.llms import OpenAI | ||
from langchain.prompts import PromptTemplate | ||
import os | ||
|
||
|
||
@post | ||
def generate(startup_name: str, startup_idea: str) -> str: | ||
prompt_template = """ | ||
default_prompt = """ | ||
please write a short linkedin message (2 SENTENCES MAX) to an investor pitchin the following startup: | ||
startup name: {startup_name} | ||
startup idea: {startup_idea}""" | ||
llm = OpenAI(temperature=0.9) | ||
|
||
|
||
@post | ||
def generate(startup_name: str, startup_idea: str, prompt_template: TextParam = default_prompt, temperature: FloatParam = 0.5) -> str: | ||
llm = OpenAI(temperature=temperature) | ||
prompt = PromptTemplate( | ||
input_variables=["startup_name", "startup_idea"], | ||
template=prompt_template) | ||
|
||
chain = LLMChain(llm=llm, prompt=prompt) | ||
output = chain.run(startup_name=startup_name, startup_idea=startup_idea) | ||
return output | ||
|
||
|
||
if __name__ == "__main__": | ||
load_dotenv() | ||
print(generate("Agenta AI", "Developer tool for LLM-powered apps")) |
This file was deleted.
Oops, something went wrong.