Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLM Templates - Created startup technical ideas LLM chat app #958

Merged
merged 21 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d05ca69
Feat - created file input url sdk type
aybruhm Nov 28, 2023
06aef48
Update - import FileInputURL to sdk __init__ modules
aybruhm Nov 28, 2023
9628573
Update - added annotation and default value to FileInputURL schema
aybruhm Nov 28, 2023
cc8894f
:art: Format - ran black
aybruhm Nov 28, 2023
dac5c47
Feat - introduce choice mixin to be used in MultipleChoiceParam sdk type
aybruhm Nov 28, 2023
e55115a
Update - modified multiple choice param schema override
aybruhm Nov 28, 2023
1fd9162
Update - add new parameters to application
aybruhm Nov 28, 2023
a7b16f5
Refactor - moved startup_feature_ideas from experimental to examples/
aybruhm Nov 28, 2023
9c45043
Cleanup - remove .gitignore file
aybruhm Nov 28, 2023
3f32477
Refactor - renamed startup_feature_ideas to startup_technical_ideas
aybruhm Nov 28, 2023
7e2be9f
Feat - added startup_technical_ideas llm app as a template to use
aybruhm Nov 28, 2023
b289e4c
Merge branch 'main' into gh/create-llm-app-temp-for-chat
aybruhm Nov 28, 2023
9031356
Cleanup - remove file input type from branch
aybruhm Nov 28, 2023
9328f4f
:art: Format - ran black
aybruhm Nov 28, 2023
1132b91
Refactor - added missing 't'
aybruhm Nov 28, 2023
6ce79ca
Cleanup - remove unused import(s)
aybruhm Nov 28, 2023
11f774e
Update - move model to ag.config parameter
aybruhm Nov 28, 2023
7883ea2
Update - revert back to original method
aybruhm Nov 28, 2023
17efa95
Update - added max_tokens to default parameters
aybruhm Nov 28, 2023
3064679
Update - remove startup_technical_ideas from agenta templates/ directory
aybruhm Nov 28, 2023
c3960d7
Update - make tiny adjustments
aybruhm Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions agenta-cli/agenta/sdk/agenta_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
import agenta
from fastapi import Body, FastAPI, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.models import Server
from fastapi.responses import JSONResponse

from .context import get_contexts, save_context
from .context import save_context
from .router import router as router
from .types import (
Context,
Expand Down Expand Up @@ -345,7 +344,6 @@ def find_in_schema(schema: dict, param_name: str, xparam: str):
f"Body_{func_name}_{endpoint}_post"
]["properties"]
for param_name, param_val in params.items():
# print(param_name, param_val)
if isinstance(param_val, MultipleChoiceParam):
subschema = find_in_schema(schema_to_override, param_name, "choice")
default = str(param_val)
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/agenta/sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Message(BaseModel):
class MessagesInput(list):
"""Messages Input for Chat-completion.

Parameters:
Args:
messages (List[Dict[str, str]]): The list of messages inputs.
Required. Each message should be a dictionary with "role" and "content" keys.

Expand Down
7 changes: 0 additions & 7 deletions examples/experimental/startup_feature_ideas/.gitignore

This file was deleted.

31 changes: 0 additions & 31 deletions examples/experimental/startup_feature_ideas/app.py

This file was deleted.

37 changes: 37 additions & 0 deletions examples/startup_technical_ideas/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import agenta as ag
from agenta import FloatParam, MessagesInput, MultipleChoiceParam
from openai import OpenAI

client = OpenAI()

SYSTEM_PROMPT = "You have expertise in offering technical ideas to startups."
CHAT_LLM_GPT = [
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k-0613",
"gpt-4",
]

ag.init(app_name="technical_ideas", base_name="app")
ag.config.default(
temperature=FloatParam(0.2),
model=MultipleChoiceParam("gpt-3.5-turbo", CHAT_LLM_GPT),
max_tokens=ag.IntParam(-1, -1, 4000),
aybruhm marked this conversation as resolved.
Show resolved Hide resolved
prompt_system=ag.TextParam(SYSTEM_PROMPT),
)


@ag.entrypoint
def chat(
messages: MessagesInput = MessagesInput(),
) -> str:
messages = [{"role": "system", "content": ag.config.system_prompt}] + messages
max_tokens = ag.config.max_tokens if ag.config.max_tokens != -1 else None
chat_completion = client.chat.completions.create(
model=ag.config.model,
messages=messages,
temperature=ag.config.temperature,
max_tokens=max_tokens,
)
return chat_completion.choices[0].message.content
Loading