-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(assistant-ai): swagger API documentation and readme update (#28)
- Loading branch information
1 parent
6ab1042
commit 4efea45
Showing
47 changed files
with
671 additions
and
494 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# OpenAI API Key | ||
OPENAI_API_KEY= | ||
|
||
# Assistant ID - leave it empty if you don't have an assistant yet | ||
ASSISTANT_ID= |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
apps/api-e2e/src/ai-restaurants-api/ai-restaurants-api.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,6 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { GetAnimalAgent } from './get-animal.agent'; | ||
import { AgentModule } from '@boldare/ai-assistant'; | ||
|
||
@Module({ | ||
imports: [], | ||
imports: [AgentModule], | ||
providers: [GetAnimalAgent], | ||
}) | ||
export class AgentsModule {} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { AssistantCreateParams } from 'openai/resources/beta'; | ||
import { AgentBase, AgentData, AgentService } from '@boldare/ai-assistant'; | ||
|
||
@Injectable() | ||
export class GetAnimalAgent extends AgentBase { | ||
definition: AssistantCreateParams.AssistantToolsFunction = { | ||
type: 'function', | ||
function: { | ||
name: this.constructor.name, | ||
description: `Display name od the animal`, | ||
parameters: { | ||
type: 'object', | ||
properties: { | ||
animal: { | ||
type: 'string', | ||
description: `Type of the animal`, | ||
}, | ||
}, | ||
required: ['animal'], | ||
}, | ||
}, | ||
}; | ||
|
||
constructor(protected readonly agentService: AgentService) { | ||
super(agentService); | ||
} | ||
|
||
async output(data: AgentData): Promise<string> { | ||
try { | ||
const params = JSON.parse(data.params); | ||
const animal = params?.animal; | ||
const animals = [ | ||
{ id: 1, animal: 'dog', name: 'Rex' }, | ||
{ id: 2, animal: 'cat', name: 'Mittens' }, | ||
{ id: 3, animal: 'bird', name: 'Tweety' }, | ||
{ id: 4, animal: 'fish', name: 'Goldie' }, | ||
{ id: 5, animal: 'rabbit', name: 'Bugs' }, | ||
]; | ||
|
||
if (!animal) { | ||
return 'No animal provided'; | ||
} | ||
|
||
return animals.find(a => a.animal === animal)?.name || 'No such animal'; | ||
} catch (errors) { | ||
return `Invalid data: ${JSON.stringify(errors)}`; | ||
} | ||
} | ||
} |
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,8 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AssistantModule } from '@boldare/ai-assistant'; | ||
import { assistantConfig } from './chat.config'; | ||
import { AgentsModule } from './agents/agents.module'; | ||
|
||
@Module({ | ||
imports: [AssistantModule.forRoot(assistantConfig)], | ||
imports: [AssistantModule.forRoot(assistantConfig), AgentsModule], | ||
}) | ||
export class ChatModule {} |
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
Oops, something went wrong.