Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0d4e0bd
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 24, 2025
57632a5
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 24, 2025
fd0b462
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 24, 2025
e4c35f2
TLK-2709 - Github Tool Implementation - temporary commit
EugeneLightsOn Jan 27, 2025
f478720
TLK-2709 - Github Tool Implementation - temporary commit
EugeneLightsOn Jan 27, 2025
2b33a13
TLK-2709 - Github Tool Implementation - temporary commit
EugeneLightsOn Jan 28, 2025
e1beb5d
TLK-2709 - Github Tool Implementation - temporary commit
EugeneLightsOn Jan 29, 2025
25fc2c8
TLK-2709 - Github Tool Implementation - temporary commit
EugeneLightsOn Jan 29, 2025
5d81b79
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 30, 2025
8d0ad72
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 30, 2025
d1eadb1
TLK-2709 - Github Tool Implementation + small fixes
EugeneLightsOn Jan 30, 2025
bee03e9
Merge branch 'main' into eugene/tlk-2709-add-github-tool
EugeneLightsOn Jan 30, 2025
107705e
TLK-2709 - Github Tool Implementation format
EugeneLightsOn Jan 30, 2025
913e1b1
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 30, 2025
c980613
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 30, 2025
3914e8c
TLK-2709 - Github Tool Implementation
EugeneLightsOn Jan 30, 2025
120ea6f
TLK-2709 - Github Tool Implementation review fixes
EugeneLightsOn Jan 30, 2025
2ae7fc8
TLK-2709 - Github Tool Implementation review fixes
EugeneLightsOn Jan 30, 2025
0809c75
Merge branch 'main' into eugene/tlk-2709-add-github-tool
EugeneLightsOn Jan 30, 2025
afcf1e0
TLK-2709 - Github Tool Implementation review fixes
EugeneLightsOn Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Toolkit is a deployable all-in-one RAG application that enables users to quickly
- [How to setup Google Drive](/docs/custom_tool_guides/google_drive.md)
- [How to setup Gmail](/docs/custom_tool_guides/gmail.md)
- [How to setup Slack Tool](/docs/custom_tool_guides/slack.md)
- [How to setup Github Tool](/docs/custom_tool_guides/github.md)
- [How to setup Google Text-to-Speech](/docs/text_to_speech.md)
- [How to add authentication](/docs/auth_guide.md)
- [How to deploy toolkit services](/docs/service_deployments.md)
Expand Down
50 changes: 50 additions & 0 deletions docs/custom_tool_guides/github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Github Tool Setup

To set up the Github tool you will need a Github application. Follow the steps below to set it up:

## 1. Create a Github App

Head to the [Github Settings](https://github.com/settings/apps) and create a new app.
Specify App [permissions](https://docs.github.com/rest/overview/permissions-required-for-github-apps), Callback URL (for local setup - http://localhost:8000/v1/tool/auth).
Uncheck the `Webhook->Active` option. After creating the app, you will see the `General` section. Copy the `Client ID`, generate and copy `Client Secret` values.
That will be used for the environment variables specified above.
This tool also support OAuth Apps. See the [documentation](https://docs.github.com/en/apps/oauth-apps) for more information.

## 2. Set Up Environment Variables
Set the configuration in the `configuration.yaml`
```yaml
github:
default_repos:
- repo1
- repo2
user_scopes:
- public_repo
- read:org
```
Then set the following secrets variables. You can either set the below values in your `secrets.yaml` file:
```yaml
github:
client_id: <your_client_id from step 1>
client_secret: <your_client_secret from step 1>
```
or update your `.env` configuration to contain:
```dotenv
GITHUB_CLIENT_ID=<your_client_id from step 1>
GITHUB_CLIENT_SECRET=<your_client_secret from step 1>
GITHUB_DEFAULT_REPOS=["repo1","repo2"]
GITHUB_USER_SCOPES=["public_repo","read:org"]
```
Please note if the default repos are not set, the tool will process over all user repos.

## 3. Run the Backend and Frontend

run next command to start the backend and frontend:

```bash
make dev
```

## 4. Troubleshooting

If you encounter any issues with OAuth, please check the following [link](https://api.Github.com/authentication/oauth-v2#errors)
67 changes: 54 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ llama-index-embeddings-cohere = "^0.2.1"
google-cloud-texttospeech = "^2.18.0"
slack-sdk = "^3.33.1"
onnxruntime = "1.19.2"
pygithub = "^2.5.0"

[tool.poetry.group.dev]
optional = true
Expand Down
5 changes: 5 additions & 0 deletions src/backend/chat/collate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from backend.model_deployments.base import BaseDeployment
from backend.schemas.context import Context
from backend.tools.base import ToolError

RELEVANCE_THRESHOLD = 0.1

Expand Down Expand Up @@ -62,6 +63,10 @@ async def rerank_and_chunk(

chunked_outputs = []
for output in tool_result["outputs"]:
if isinstance(output, ToolError):
reranked_results[tool_call_hashable] = tool_result
continue

text = output.get("text")

if not text:
Expand Down
6 changes: 6 additions & 0 deletions src/backend/config/configuration.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ tools:
slack:
user_scopes:
- search:read
github:
user_scopes:
- public_repo
default_repos:
- cohere-ai/cohere-toolkit
- EugeneLightsOn/cohere-toolkit
# To disable the use of the tools preamble, set it to false
use_tools_preamble: true
feature_flags:
Expand Down
1 change: 1 addition & 0 deletions src/backend/config/default_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_default_agent() -> AgentPublic:
Tool.Search_File.value.ID,
Tool.Python_Interpreter.value.ID,
Tool.Hybrid_Web_Search.value.ID,
Tool.Github.value.ID,
],
tools_metadata=[],
deployment=DEFAULT_DEPLOYMENT,
Expand Down
3 changes: 3 additions & 0 deletions src/backend/config/secrets.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ tools:
gmail:
client_id:
client_secret:
github:
client_id:
client_secret:
auth:
secret_key:
google_oauth:
Expand Down
29 changes: 28 additions & 1 deletion src/backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,38 @@ class SlackSettings(BaseSettings, BaseModel):
default=None,
validation_alias=AliasChoices("SLACK_CLIENT_SECRET", "client_secret"),
)
user_scopes: Optional[str] = Field(
user_scopes: Optional[List[str]] = Field(
default=None,
validation_alias=AliasChoices(
"SLACK_USER_SCOPES", "scopes"
),
)


class GithubSettings(BaseSettings, BaseModel):
model_config = SETTINGS_CONFIG
client_id: Optional[str] = Field(
default=None,
validation_alias=AliasChoices("GITHUB_CLIENT_ID", "client_id"),
)
client_secret: Optional[str] = Field(
default=None,
validation_alias=AliasChoices("GITHUB_CLIENT_SECRET", "client_secret"),
)
user_scopes: Optional[List[str]] = Field(
default=None,
validation_alias=AliasChoices(
"GITHUB_USER_SCOPES", "user_scopes"
),
)
default_repos: Optional[List[str]] = Field(
default=None,
validation_alias=AliasChoices(
"GITHUB_DEFAULT_REPOS", "default_repos"
),
)


class TavilyWebSearchSettings(BaseSettings, BaseModel):
model_config = SETTINGS_CONFIG
api_key: Optional[str] = Field(
Expand Down Expand Up @@ -272,6 +296,9 @@ class ToolSettings(BaseSettings, BaseModel):
slack: Optional[SlackSettings] = Field(
default=SlackSettings()
)
github: Optional[GithubSettings] = Field(
default=GithubSettings()
)
gmail: Optional[GmailSettings] = Field(
default=GmailSettings()
)
Expand Down
2 changes: 2 additions & 0 deletions src/backend/config/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
TavilyWebSearch,
WebScrapeTool,
)
from backend.tools.github.tool import GithubTool

logger = LoggerFactory().get_logger()

Expand All @@ -38,6 +39,7 @@ class Tool(Enum):
Hybrid_Web_Search = HybridWebSearch
Slack = SlackTool
Gmail = GmailTool
Github = GithubTool


def get_available_tools() -> dict[str, ToolDefinition]:
Expand Down
3 changes: 2 additions & 1 deletion src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def create_app() -> FastAPI:
# Dynamically set router dependencies
# These values must be set in config/routers.py
dependencies_type = "default"
settings = Settings()
if is_authentication_enabled():
# Required to save temporary OAuth state in session
auth_secret = Settings().get('auth.secret_key')
auth_secret = settings.get('auth.secret_key')
app.add_middleware(SessionMiddleware, secret_key=auth_secret)
dependencies_type = "auth"
for router in routers:
Expand Down
4 changes: 2 additions & 2 deletions src/backend/tools/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from abc import ABC, abstractmethod
from enum import StrEnum
from typing import Any, Dict, List
from typing import Any, Dict, List, Union

import requests
from fastapi import Request
Expand Down Expand Up @@ -169,7 +169,7 @@ def get_no_results_error(cls):
@abstractmethod
async def call(
self, parameters: dict, ctx: Any, **kwargs: Any
) -> List[Dict[str, Any]]:
) -> Union[List[Dict[str, Any]], ToolError]:
...

@classmethod
Expand Down
Empty file.
Loading
Loading