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

Native Function Calling #973

Merged
merged 35 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
71b335f
Upgrade Fern
homanp Apr 16, 2024
deb7329
Update OpenAPI spec
homanp Apr 16, 2024
49f6516
Downgrade Fern
homanp Apr 17, 2024
6db3666
Gracefully handling parsing errors for structured outputs (#966)
elisalimli Apr 18, 2024
9a90e5f
fix: revert breaking change
elisalimli Apr 18, 2024
4d70a27
Merge pull request #967 from superagent-ai/bugfix/revert-returning-js…
elisalimli Apr 18, 2024
ed8c502
add 'MISTRAL' to LLMProvider enum
elisalimli Apr 18, 2024
1417896
add Mistral to SAML
elisalimli Apr 18, 2024
ff85920
feat(ui): add Mistral integration support
elisalimli Apr 18, 2024
114fbd5
feat(db): add database schemas
elisalimli Apr 18, 2024
d4337d8
feat: add groq to SAML
elisalimli Apr 18, 2024
bc183b5
feat(ui): groq integration
elisalimli Apr 18, 2024
7948610
Merge branch 'feat/mistral' into feat/native-function-calling
elisalimli Apr 19, 2024
f22d816
Merge branch 'feat/groq' into feat/native-function-calling
elisalimli Apr 19, 2024
0db604e
(Astra DB) add caller name as User-Agent header in HTTP requests to A…
hemidactylus Apr 19, 2024
e158619
Mistral Integration (#969)
elisalimli Apr 19, 2024
e27d0ce
⚡️Groq Integration (#970)
elisalimli Apr 19, 2024
cc5bb2f
Update API version
homanp Apr 19, 2024
c30bc1a
Update OpenAPI specs
homanp Apr 19, 2024
a60cb8a
fix: add JSON serialization to SuperRagTool query response
elisalimli Apr 19, 2024
dbae019
Merge pull request #971 from superagent-ai/bugfix/stringify-superrag-…
elisalimli Apr 19, 2024
97e0958
feat(db): add cohere migration
elisalimli Apr 20, 2024
28f9451
feat(saml): add cohere to SAML
elisalimli Apr 20, 2024
c357e75
feat(ui): add cohere integration
elisalimli Apr 20, 2024
183d6da
feat(ui): add cohere integration
elisalimli Apr 20, 2024
bcb1a05
Merge branch 'feat/cohere' into feat/native-function-calling
elisalimli Apr 20, 2024
f99d835
fix: indentation issue in CustomAsyncIteratorCallbackHandler
elisalimli Apr 22, 2024
95206ac
refactor: remove hypen from function name regex
elisalimli Apr 22, 2024
13d26c9
feat: add native function calling
elisalimli Apr 22, 2024
430dddb
refactor: update SAML configuration to use 'browser tool' instead of …
elisalimli Apr 22, 2024
a7c60b4
deps: upgrade litellm from version 1.35.8 to 1.35.21
elisalimli Apr 24, 2024
fcd791d
fix: handle claude 3 haiku output
elisalimli Apr 24, 2024
bf6cd15
fix: passing tool error to LLM instead of moving on
elisalimli Apr 24, 2024
3dec179
refactor: LLMAgent's get_agent method to use native function calling …
elisalimli Apr 29, 2024
a0f4560
feat: add return_direct support in LLMAgent
elisalimli Apr 29, 2024
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
33 changes: 31 additions & 2 deletions fern/apis/prod/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.2
info:
title: Superagent
description: 🥷 Run AI-agents with an API
version: 0.2.29
version: 0.2.32
servers:
- url: https://api.beta.superagent.sh
paths:
Expand Down Expand Up @@ -195,8 +195,8 @@ paths:
$ref: '#/components/schemas/HTTPValidationError'
security:
- HTTPBearer: []
x-fern-sdk-group-name: agent
x-fern-sdk-method-name: invoke
x-fern-sdk-group-name: agent
/api/v1/agents/{agent_id}/llms:
post:
tags:
Expand Down Expand Up @@ -1507,6 +1507,33 @@ paths:
$ref: '#/components/schemas/HTTPValidationError'
security:
- HTTPBearer: []
delete:
tags:
- Vector Database
summary: Delete
description: Delete a Vector Database
operationId: delete_api_v1_vector_dbs__vector_db_id__delete
parameters:
- required: true
schema:
title: Vector Db Id
type: string
name: vector_db_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- HTTPBearer: []
patch:
tags:
- Vector Database
Expand Down Expand Up @@ -1783,6 +1810,8 @@ components:
- TOGETHER_AI
- ANTHROPIC
- BEDROCK
- GROQ
- MISTRAL
type: string
description: An enumeration.
OpenAiAssistantParameters:
Expand Down
52 changes: 46 additions & 6 deletions libs/superagent/app/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from app.models.request import LLMParams as LLMParamsRequest
from app.utils.callbacks import CustomAsyncIteratorCallbackHandler
from prisma.enums import AgentType
from prisma.enums import AgentType, LLMProvider
from prisma.models import LLM, Agent


Expand All @@ -21,9 +21,21 @@ class LLMParams(BaseModel):
class LLMData(BaseModel):
llm: LLM
params: LLMParams
model: str


class AgentBase(ABC):
_input: str
_messages: list = []
prompt: Any
tools: Any
session_id: str
enable_streaming: bool
output_schema: str
callbacks: List[CustomAsyncIteratorCallbackHandler]
agent_data: Agent
llm_data: LLMData

def __init__(
self,
session_id: str,
Expand All @@ -40,10 +52,6 @@ def __init__(
self.llm_data = llm_data
self.agent_data = agent_data

_input: str
prompt: Any
tools: Any

@property
def input(self):
return self._input
Expand All @@ -52,6 +60,14 @@ def input(self):
def input(self, value: str):
self._input = value

@property
def messages(self):
return self._messages

@messages.setter
def messages(self, value: list):
self._messages = value

@property
@abstractmethod
def prompt(self) -> Any:
Expand Down Expand Up @@ -95,7 +111,31 @@ def llm_data(self):
**(params),
}

return LLMData(llm=llm, params=LLMParams.parse_obj(options))
params = LLMParams(
temperature=options.get("temperature"),
max_tokens=options.get("max_tokens"),
aws_access_key_id=(
options.get("aws_access_key_id")
if llm.provider == LLMProvider.BEDROCK
else None
),
aws_secret_access_key=(
options.get("aws_secret_access_key")
if llm.provider == LLMProvider.BEDROCK
else None
),
aws_region_name=(
options.get("aws_region_name")
if llm.provider == LLMProvider.BEDROCK
else None
),
)

return LLMData(
llm=llm,
params=LLMParams.parse_obj(options),
model=self.agent_data.llmModel or self.agent_data.metadata.get("model"),
)

async def get_agent(self):
if self.agent_data.type == AgentType.OPENAI_ASSISTANT:
Expand Down
2 changes: 1 addition & 1 deletion libs/superagent/app/agents/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _get_llm(self):

if llm_data.llm.provider == LLMProvider.OPENAI:
return ChatOpenAI(
model=LLM_MAPPING[self.agent_data.llmModel],
model=LLM_MAPPING[self.llm_data.model],
openai_api_key=llm_data.llm.apiKey,
streaming=self.enable_streaming,
callbacks=self.callbacks,
Expand Down
Loading