Skip to content

Commit

Permalink
feat: add upload file api
Browse files Browse the repository at this point in the history
  • Loading branch information
Dttbd committed Apr 25, 2024
1 parent 19a73f9 commit 9656c8c
Show file tree
Hide file tree
Showing 43 changed files with 2,067 additions and 537 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ TASKINGAI_HOST=https://api.test199.com

TEXT_EMBEDDING_MODEL_ID=TpEZlEOK

TASKINGAI_API_KEY=taxy8i3OCfeJfh0eXW0h00cF2QT7nWyy
TASKINGAI_API_KEY=taxy8i3OCfeJfh0eXW0h00cF2QT7nWyy
49 changes: 44 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,52 @@ target/
#Ipython Notebook
.ipynb_checkpoints

# PyCharm
.idea/

### macOS ###
# General
.DS_Store
.venv
.AppleDouble
.LSOverride

# test
test/.pytest_cache/
test/log/
# Icon must end with two \r
Icon

**/allure-report

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
122 changes: 64 additions & 58 deletions examples/crud/assistant_crud.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
},
{
"cell_type": "markdown",
"source": [
"# TaskingAI Assistant Module CRUD Example"
],
"metadata": {
"collapsed": false
}
},
"source": [
"# TaskingAI Assistant Module CRUD Example"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from taskingai.models import Assistant, Chat\n",
"from taskingai.assistant import Assistant, Chat\n",
"from taskingai.assistant.memory import AssistantNaiveMemory\n",
"\n",
"# choose an available chat_completion model from your project\n",
Expand All @@ -34,19 +34,21 @@
},
{
"cell_type": "markdown",
"source": [
"## Assistant Object"
],
"metadata": {
"collapsed": false
}
},
"source": [
"## Assistant Object"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from taskingai.assistant import RetrievalConfig, RetrievalMethod\n",
"\n",
"# create an assistant\n",
"def create_assistant() -> Assistant:\n",
" assistant: Assistant = taskingai.assistant.create_assistant(\n",
Expand All @@ -57,6 +59,7 @@
" memory=AssistantNaiveMemory(),\n",
" tools=[],\n",
" retrievals=[],\n",
" retrieval_configs=RetrievalConfig(top_k=3, max_tokens=4096, method=RetrievalMethod.USER_MESSAGE),\n",
" metadata={\"foo\": \"bar\"},\n",
" )\n",
" return assistant\n",
Expand All @@ -68,6 +71,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# get assistant\n",
Expand All @@ -77,69 +83,70 @@
")\n",
"\n",
"print(f\"got assistant: {assistant}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# update assistant\n",
"assistant: Assistant = taskingai.assistant.update_assistant(\n",
" assistant_id=assistant_id,\n",
" name=\"My New Assistant\",\n",
" description=\"This is my new assistant\",\n",
" retrieval_configs=RetrievalConfig(top_k=4, max_tokens=8192, method=RetrievalMethod.USER_MESSAGE),\n",
")\n",
"\n",
"print(f\"updated assistant: {assistant}\\n\")\n"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# delete assistant\n",
"taskingai.assistant.delete_assistant(assistant_id=assistant_id)\n",
"print(f\"deleted assistant: {assistant_id}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# list assistants\n",
"assistants = taskingai.assistant.list_assistants()\n",
"assistant_ids = [assistant.assistant_id for assistant in assistants]\n",
"# ensure the assistant we deleted is not in the list\n",
"print(f\"f{assistant_id} in assistant_ids: {assistant_id in assistant_ids}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"source": [
"## Chat Object"
],
"metadata": {
"collapsed": false
}
},
"source": [
"## Chat Object"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# create a new assistant\n",
Expand All @@ -148,16 +155,17 @@
"# create a chat\n",
"chat: Chat = taskingai.assistant.create_chat(\n",
" assistant_id=assistant.assistant_id,\n",
" name=\"my chat\",\n",
")\n",
"print(f\"created chat: {chat.chat_id} for assistant: {assistant.assistant_id}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# get chat\n",
Expand All @@ -167,31 +175,32 @@
" chat_id=chat_id,\n",
")\n",
"print(f\"chat: {chat}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# update chat\n",
"chat: Chat = taskingai.assistant.update_chat(\n",
" assistant_id=assistant.assistant_id,\n",
" chat_id=chat_id,\n",
" name=\"my chat new name\",\n",
" metadata={\"foo\": \"bar\"},\n",
")\n",
"print(f\"updated chat: {chat}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# delete chat\n",
Expand All @@ -200,14 +209,14 @@
" chat_id=chat_id,\n",
")\n",
"print(f\"deleted chat: {chat_id}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# list chats \n",
Expand All @@ -220,32 +229,29 @@
" assistant_id=assistant.assistant_id,\n",
")\n",
"print(f\"num chats = {len(chats)}\\n\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# delete assistant\n",
"taskingai.assistant.delete_assistant(assistant_id=assistant.assistant_id)"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"display_name": "Python 3 (ipykernel)"
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 9656c8c

Please sign in to comment.