From c0c862b4bdb9866f2cd7d5b4195c0bfd100750f3 Mon Sep 17 00:00:00 2001 From: Siddharth Balyan Date: Wed, 3 Jul 2024 11:52:45 +0530 Subject: [PATCH] add optional id tests; fix pytype, remove model field --- .../agents_api/autogen/openapi_model.py | 6 +----- agents-api/tests/test_agents.py | 3 --- agents-api/tests/test_sessions.py | 2 -- agents-api/tests/test_users.py | 1 - mock_openapi.yaml | 3 --- openapi.yaml | 3 --- sdks/python/julep/api/client.py | 10 ---------- sdks/python/julep/api/types/chat_settings.py | 1 - sdks/ts/src/api/models/ChatSettings.ts | 4 ---- sdks/ts/src/api/schemas/$ChatSettings.ts | 4 ---- sdks/ts/tests/agents.test.ts | 12 ++++++++++-- sdks/ts/tests/sessions.test.ts | 19 ++++++++++++++++++- sdks/ts/tests/users.test.ts | 9 ++++++++- 13 files changed, 37 insertions(+), 40 deletions(-) diff --git a/agents-api/agents_api/autogen/openapi_model.py b/agents-api/agents_api/autogen/openapi_model.py index 36b56e857..e6c38fd7d 100644 --- a/agents-api/agents_api/autogen/openapi_model.py +++ b/agents-api/agents_api/autogen/openapi_model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-07-03T01:16:01+00:00 +# timestamp: 2024-07-03T06:12:30+00:00 from __future__ import annotations @@ -514,10 +514,6 @@ class ChatSettings(BaseModel): """ Generation preset name (problem_solving|conversational|fun|prose|creative|business|deterministic|code|multilingual) """ - model: str | None = None - """ - Model name - """ class Preset1(str, Enum): diff --git a/agents-api/tests/test_agents.py b/agents-api/tests/test_agents.py index 05ee86053..8c4a5cd73 100644 --- a/agents-api/tests/test_agents.py +++ b/agents-api/tests/test_agents.py @@ -9,7 +9,6 @@ def _(client=client): agent = client.agents.create( name="Samantha", - id=uuid.uuid4(), about="about Samantha", instructions=[ "non-important content", @@ -132,7 +131,6 @@ def _(client=client): async def _(client=async_client): agent = await client.agents.create( name="Samantha", - id=uuid.uuid4(), about="about Samantha", instructions=[ "non-important content", @@ -172,7 +170,6 @@ def _(client=client): try: client.agents.create( name="Samantha", - id=uuid.uuid4(), about="about Samantha", instructions=[ "non-important content", diff --git a/agents-api/tests/test_sessions.py b/agents-api/tests/test_sessions.py index e324c5f36..811c065e1 100644 --- a/agents-api/tests/test_sessions.py +++ b/agents-api/tests/test_sessions.py @@ -64,7 +64,6 @@ def _(user=user, agent=agent, client=client): user_id=user.id, agent_id=agent.id, situation="test situation", - id=uuid.uuid4(), ) assert isinstance(response, ResourceCreatedResponse) @@ -79,7 +78,6 @@ async def _(user=user, agent=agent, client=async_client): agent_id=agent.id, situation="test situation", id=uuid.uuid4(), - ) assert isinstance(response, ResourceCreatedResponse) diff --git a/agents-api/tests/test_users.py b/agents-api/tests/test_users.py index ec2174101..9fb1b315d 100644 --- a/agents-api/tests/test_users.py +++ b/agents-api/tests/test_users.py @@ -22,7 +22,6 @@ def _(client=client): async def _(client=async_client): response = await client.users.create( name="test user", - id=uuid.uuid4(), about="test user about", ) diff --git a/mock_openapi.yaml b/mock_openapi.yaml index 8472d412c..11c7e690c 100644 --- a/mock_openapi.yaml +++ b/mock_openapi.yaml @@ -1993,9 +1993,6 @@ components: - deterministic - code - multilingual - model: - type: string - description: Model name AgentDefaultSettings: type: object properties: diff --git a/openapi.yaml b/openapi.yaml index 28e277995..f30ca8737 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1993,9 +1993,6 @@ components: - deterministic - code - multilingual - model: - type: string - description: Model name AgentDefaultSettings: type: object properties: diff --git a/sdks/python/julep/api/client.py b/sdks/python/julep/api/client.py index cee92bb74..65b757f0e 100644 --- a/sdks/python/julep/api/client.py +++ b/sdks/python/julep/api/client.py @@ -771,7 +771,6 @@ def chat( top_p: typing.Optional[float] = OMIT, min_p: typing.Optional[float] = OMIT, preset: typing.Optional[ChatSettingsPreset] = OMIT, - model: typing.Optional[str] = OMIT, recall: typing.Optional[bool] = OMIT, record: typing.Optional[bool] = OMIT, remember: typing.Optional[bool] = OMIT, @@ -822,8 +821,6 @@ def chat( - preset: typing.Optional[ChatSettingsPreset]. Generation preset name (problem_solving|conversational|fun|prose|creative|business|deterministic|code|multilingual) - - model: typing.Optional[str]. Model name - - recall: typing.Optional[bool]. Whether previous memories should be recalled or not - record: typing.Optional[bool]. Whether this interaction should be recorded in history or not @@ -878,8 +875,6 @@ def chat( _request["min_p"] = min_p if preset is not OMIT: _request["preset"] = preset.value - if model is not OMIT: - _request["model"] = model if recall is not OMIT: _request["recall"] = recall if record is not OMIT: @@ -2582,7 +2577,6 @@ async def chat( top_p: typing.Optional[float] = OMIT, min_p: typing.Optional[float] = OMIT, preset: typing.Optional[ChatSettingsPreset] = OMIT, - model: typing.Optional[str] = OMIT, recall: typing.Optional[bool] = OMIT, record: typing.Optional[bool] = OMIT, remember: typing.Optional[bool] = OMIT, @@ -2633,8 +2627,6 @@ async def chat( - preset: typing.Optional[ChatSettingsPreset]. Generation preset name (problem_solving|conversational|fun|prose|creative|business|deterministic|code|multilingual) - - model: typing.Optional[str]. Model name - - recall: typing.Optional[bool]. Whether previous memories should be recalled or not - record: typing.Optional[bool]. Whether this interaction should be recorded in history or not @@ -2689,8 +2681,6 @@ async def chat( _request["min_p"] = min_p if preset is not OMIT: _request["preset"] = preset.value - if model is not OMIT: - _request["model"] = model if recall is not OMIT: _request["recall"] = recall if record is not OMIT: diff --git a/sdks/python/julep/api/types/chat_settings.py b/sdks/python/julep/api/types/chat_settings.py index 11659754d..ebaa5b991 100644 --- a/sdks/python/julep/api/types/chat_settings.py +++ b/sdks/python/julep/api/types/chat_settings.py @@ -87,7 +87,6 @@ class ChatSettings(pydantic.BaseModel): "multilingual)\n" ) ) - model: typing.Optional[str] = pydantic.Field(description="Model name") def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = { diff --git a/sdks/ts/src/api/models/ChatSettings.ts b/sdks/ts/src/api/models/ChatSettings.ts index c6c899ef3..811fe807f 100644 --- a/sdks/ts/src/api/models/ChatSettings.ts +++ b/sdks/ts/src/api/models/ChatSettings.ts @@ -97,8 +97,4 @@ export type ChatSettings = { | "deterministic" | "code" | "multilingual"; - /** - * Model name - */ - model?: string; }; diff --git a/sdks/ts/src/api/schemas/$ChatSettings.ts b/sdks/ts/src/api/schemas/$ChatSettings.ts index 924a8e381..094519a8e 100644 --- a/sdks/ts/src/api/schemas/$ChatSettings.ts +++ b/sdks/ts/src/api/schemas/$ChatSettings.ts @@ -120,9 +120,5 @@ export const $ChatSettings = { preset: { type: "Enum", }, - model: { - type: "string", - description: `Model name`, - }, }, } as const; diff --git a/sdks/ts/tests/agents.test.ts b/sdks/ts/tests/agents.test.ts index ad0fdbd3d..0b6e0338f 100644 --- a/sdks/ts/tests/agents.test.ts +++ b/sdks/ts/tests/agents.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "@jest/globals"; import { Agent } from "../src/api"; - +import { v4 as uuidv4 } from "uuid"; import { setupClient } from "./fixtures"; const client = setupClient(); @@ -14,6 +14,14 @@ const mockAgent = { default_settings: { temperature: 0.5 }, }; +const mockAgentWithId = { + name: "test agent", + id: uuidv4(), + about: "test agent about", + instructions: ["test agent instructions"], + default_settings: { temperature: 0.5 }, +}; + const mockAgentUpdate = { name: "updated agent", about: "updated agent about", @@ -36,7 +44,7 @@ describe("Julep Client Tests", () => { test("agents.create single instruction", async () => { const response = await client.agents.create({ - ...mockAgent, + ...mockAgentWithId, instructions: "test agent instructions", }); diff --git a/sdks/ts/tests/sessions.test.ts b/sdks/ts/tests/sessions.test.ts index d174f2ba5..c33a79cf1 100644 --- a/sdks/ts/tests/sessions.test.ts +++ b/sdks/ts/tests/sessions.test.ts @@ -1,6 +1,6 @@ // sessions.test.ts import { afterAll, beforeAll, describe, expect, it } from "@jest/globals"; - +import { v4 as uuidv4 } from "uuid"; import { setupClient } from "./fixtures"; // Adjust path if necessary import { Agent, User } from "../src/api"; import { Client } from "../src"; @@ -26,6 +26,11 @@ const mockSession = { situation: "test situation", }; +const mockSessionWithId = { + id: uuidv4(), + situation: "test situation", +}; + const mockSessionWithTemplate = { situation: "Say 'hello {{ session.metadata.arg }}'", metadata: { arg: "banana" }, @@ -65,6 +70,18 @@ describe("Sessions API", () => { expect(response).toBeDefined(); expect(response).toHaveProperty("created_at"); }); + it("sessions.create.with.ID", async () => { + const response = await client.sessions.create({ + userId: testUser.id, + agentId: testAgent.id, + ...mockSessionWithId, + }); + + testSessionId = response.id; + + expect(response).toBeDefined(); + expect(response).toHaveProperty("created_at"); + }); it("sessions.get", async () => { const response = await client.sessions.get(testSessionId); diff --git a/sdks/ts/tests/users.test.ts b/sdks/ts/tests/users.test.ts index 61fd29155..fa9b41608 100644 --- a/sdks/ts/tests/users.test.ts +++ b/sdks/ts/tests/users.test.ts @@ -1,6 +1,7 @@ // tests/user.test.ts import { beforeAll, describe, expect, test } from "@jest/globals"; +import { v4 as uuidv4 } from "uuid"; import { setupClient } from "./fixtures"; import { Client } from "../src"; @@ -16,6 +17,12 @@ const mockUserUpdate = { about: "updated user about", }; +const mockUserWithId = { + name: "test user", + id: uuidv4(), + about: "test user about", +}; + describe("User API", () => { let client: Client; let testUser: User; @@ -25,7 +32,7 @@ describe("User API", () => { }); test("users.create", async () => { - const response = await client.users.create(mockUser); + const response = await client.users.create(mockUserWithId); testUser = response;