Skip to content

Commit

Permalink
Merge pull request #958 from Agenta-AI/gh/create-llm-app-temp-for-chat
Browse files Browse the repository at this point in the history
LLM Templates - Created startup technical ideas LLM chat app
  • Loading branch information
mmabrouk authored Nov 29, 2023
2 parents aba4db6 + c3960d7 commit 35fe985
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 42 deletions.
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),
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

0 comments on commit 35fe985

Please sign in to comment.