Skip to content

Commit 249e22f

Browse files
Add architecture diagram and description to the README
1 parent b88ce78 commit 249e22f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,36 @@ If your OPENAI_API_KEY or ASSISTANT_ID are not set, you will be redirected to `/
4141

4242
The assistant is capable of multi-step workflows involving multiple chained tool calls, including file searches, code execution, and calling custom functions. Tool calls will be displayed in the chat as they are processed.
4343

44+
## Architecture
45+
46+
When the user client sends a message to the application server, the server forwards the message to the OpenAI Assistants API. The assistant can reply with either a message to the user (which the server simply forwards to the client) or a tool call (which must be executed before the assistant can proceed with the conversation).
47+
48+
The Assistants API supports three types of tool calls:
49+
50+
- Code Interpreter
51+
- File Search
52+
- Custom functions
53+
54+
Code Interpreter and File Search tool calls are executed on OpenAI's servers, while custom functions are executed on the application server.
55+
56+
For custom function calls, the assistant will send the application server a JSON object with the function name and arguments (which the application server forwards to the user client for visibility). The application server will then execute the function and return the result to both the assistant and the client. The assistant will then respond to the application server with either another tool call or a final message to the user interpreting the results, which the server forwards to the client.
57+
58+
```mermaid
59+
graph TB
60+
subgraph "Application"
61+
A[Browser Client] --> |"User messages"|C[Chat Application Server]
62+
C -->|"Assistant messages, tool calls, tool results"| A
63+
end
64+
65+
subgraph "OpenAI Assistants API"
66+
D[Assistant Model] -->|"Assistant messages and custom tool calls"| C
67+
D -->|"Code Interpreter<br>or File Search tool calls"| E[OpenAI Function Executor]
68+
E -->|"Result"| D
69+
C -->|"User messages or custom tool call results"| D
70+
E -->|"Result"| C
71+
end
72+
```
73+
4474
## Defining Your Own Custom Functions
4575

4676
Define custom functions in the `utils/custom_functions.py` file. An example `get_weather` function is provided. You will need to import your function in `routers/chat.py` and add your execution logic to the `event_generator` function (search for `get_weather` in that file to see a function execution example). See also `templates/components/weather-widget.html` for an example widget for displaying the function call results.

0 commit comments

Comments
 (0)