Skip to content

Commit

Permalink
Update API endpoint URL and add new knowledge base endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gharbat committed Mar 5, 2024
1 parent 95096e5 commit f56f05c
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 2 deletions.
40 changes: 40 additions & 0 deletions copilot-widget/lib/contexts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

<script src="https://cloud.opencopilot.so/pilot.js"></script>
<script>
const options = {
apiUrl: "https://api.opencopilot.so/backend",
initialMessage: "How are the things",
token: "sxl342VFYrddsvKF",
defaultOpen: true,
triggerSelector: "#triggerSelector",
socketUrl: "https://api.opencopilot.so",
headers: {
// optional: you can pass your authentication tokens to the copilot or any other header you want to send with every request
Authorization: "Bearer your_auth_token_goes_here",
AnyKey: "AnyValue"
},
queryParams :{
// optional: you can pass your query params to the copilot or any other query param you want to send with every request
shanur: "is da boss (libral) (gays defnder)",
AnyKey: "AnyValue",

},

user:{
name:"Default User"
},
containerProps:{
style:{
// optional: you can pass any style you want to the container
width: "400px",
height: "500px",
position: "fixed",
bottom: "0",
right: "0",
zIndex: "9999",
},
className:"your class name" // if u are using tailwindcss or any className you can use the class name here
}
}
window.addEventListener("DOMContentLoaded", ()=>initAiCoPilot(options));
</script>
2 changes: 1 addition & 1 deletion docs/api-reference/endpoint/get.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Get All Copilots"
api: "GET https://cloud.opencopilot.so/backend/copilot"
api: "GET https://api.opencopilot.so/backend/copilot"
description: "Get a list of all copilots in the database."
---

Expand Down
48 changes: 48 additions & 0 deletions docs/api-reference/endpoint/ingest-knowldge.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "Ingest Knowledge (alpha)"
api: "POST https://api.opencopilot.so/backend/knowledge/:bot_id"
description: "Ingest knowledge into the copilot."
---

<Warning>
**Important**: This endpoint is in alpha and may change in the future. please report any issues or feedback to the [issue tracker](https://github.com/openchatai/OpenCopilot/issues/new/choose).
</Warning>

<Warning>
**Important**: this endpoint only supports URLs, if you have a local file that you want to ingest, you can upload it to a cloud storage service and provide the URL to the file.
</Warning>


# Ingest Knowledge
Knowledge is any information that the copilot can use to answer questions. as for now, the copilot can ingest knowledge in the following formats:

- Website: when you provide a URL, the copilot will scrape the content of the website recursively and ingest the content into its knowledge base, you can also provide a list of URLs to scrape.
- Files: you can provide a list of files to ingest, the copilot will ingest the content of the files into its knowledge base, currently, the copilot supports the following file types:
- PDF
- Markdown



<RequestExample>

```bash Example Request
curl --location 'http://localhost:8888/backend/knowldgebase/:bot_id' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"sources": ["https://en.wikipedia.org/wiki/Huffman_coding", "https://example.com/file.pdf"]
}'
```
</RequestExample>

<ResponseExample>

```json Response
[
{
"message": "Knowledge has been queued for ingestion"
}
]
```

</ResponseExample>
26 changes: 26 additions & 0 deletions docs/api-reference/endpoint/stages:.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
stages:
- deploy

update-copilot-actions:
stage: deploy
when: manual
script:
- >
echo "Updating Copilot actions..."
# Delete all actions from Copilot using environment variables for ID and token
curl -f --location --request DELETE "https://api.opencopilot.so/backend/actions/bot/$COPILOT_ID" \
--header 'Accept: application/json' \
--header "Authorization: Bearer $AUTH_TOKEN"
# Wait a bit for the delete action to propagate
sleep 5
# Import actions from the updated Swagger file using environment variables
curl -f --location --request PUT "https://api.opencopilot.so/backend/actions/bot/$COPILOT_ID/import-from-swagger" \
--header 'Accept: application/json' \
--header "Authorization: Bearer $AUTH_TOKEN" \
--form 'file=@"./swagger.json"'
echo "Copilot actions updated."
image: curlimages/curl:latest # Use an image with curl installed
13 changes: 12 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,22 @@
"pages": [
"api-notes",
"api-reference/endpoint/get",
"api-reference/endpoint/delete",
"api-reference/endpoint/delete"
]
},
{
"group": "Actions",
"pages": [
"api-reference/endpoint/delete-all-actions",
"api-reference/endpoint/import-actions-from-swagger"
]
},
{
"group": "Knowledge Base",
"pages": [
"api-reference/endpoint/ingest-knowldge"
]
},
{
"group": "Chat API",
"pages": [
Expand Down

0 comments on commit f56f05c

Please sign in to comment.