An open API service indexing awesome lists of open source software.

https://github.com/dcarpintero/create-cohere-connector

Bootstrap a custom Cohere Connector to enhance Cohere's LLMs with dynamic, up-to-date data.
https://github.com/dcarpintero/create-cohere-connector

cohere-ai cohere-connectors generative-ai large-language-models retrieval-augmented-generation

Last synced: 7 months ago
JSON representation

Bootstrap a custom Cohere Connector to enhance Cohere's LLMs with dynamic, up-to-date data.

Awesome Lists containing this project

README

          

# Create Cohere Connector [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/dcarpintero/create-cohere-connector/) [![PyPi](https://img.shields.io/pypi/v/create-cohere-connector)](https://pypi.org/project/create-cohere-connector/)

Generates a custom Cohere Connector with one command. [Cohere Connectors](https://docs.cohere.com/docs/connectors) enable to combine Cohere's large language models (LLMs), which power the [Chat API](https://docs.cohere.com/docs/cochat-beta), with up-to-date factual information. They enhance Cohere's retrieval augmented generation (RAG) offering, and can respond to user questions and prompts with substantive, grounded generations that contain citations to external public or private knowledge bases.

Note that this is an experimental project. If something doesnโ€™t work, please [file an issue](https://github.com/dcarpintero/create-cohere-connector/issues/new).

**You might also refer to the official Cohere repo for Connectors: https://github.com/cohere-ai/quick-start-connectors**

## ๐Ÿงฎ What is included?

Your environment will have everything you need to quickly prototype and deploy a custom Cohere Connector:

- ``API service`` implementing the required ``search`` endpoint using [FastAPI](https://fastapi.tiangolo.com/) (support for [Flask](https://flask.palletsprojects.com/) is planned).
- ``Bearer Token Authentication`` using the Authorization header in HTTP requests.
- ``Pydantic models`` for data validation and serialization.
- ``Client class`` to retrieve data from a custom data source.
- ``Deploy script`` to register your connector with Cohere.

## ๐Ÿš€ Quickstart

1. Install ``create-cohere-connector`` package:

You might install this package globall:

```sh
poetry self add poetry-scaffold
```

or within a virtual environment:

```sh
# Windows
py -m venv .venv
.venv\scripts\activate
```

```sh
# macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
```

```sh
pip3 install create-cohere-connector
```

2. Bootstrap your project:

```sh
poetry run create-cohere-connector
```

This will prompt for a project name:

```sh
Project name [myconnector]: hello-connector
Api framework [FastAPI]: FastAPI
Authentication [Bearer]: Bearer
Caching [None]: None
```

generate the initial project structure:

```
myconnector
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ deploy.py
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ poetry.lock
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ provider
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ client.py
โ”œโ”€โ”€ provider.py
โ”œโ”€โ”€ exceptions.py
โ””โ”€โ”€ datamodels.py
```

and install dependencies:

```sh
โœ… Project created successfully!
```



3. Set environment variables

You might rename ``.env_template`` to ``.env``, and complete it.

4. Span a shell within the virtual environment

```sh
poetry shell
```

5. Install dependencies

```sh
poetry config virtualenvs.in-project true
poetry install --no-root
```

6. Start API service

```sh
poetry run uvicorn app:app --app-dir provider --port 5000 --reload
```

7. Deploy Cohere Connector

```sh
python deploy.py
```



## ๐Ÿ‘ฉโ€๐Ÿ’ป Contributions

If you would like to contribute, here are some features that we are planning to add:

- Improve Poetry virtual environment creation
- Flask support
- Semantic caching
- OAuth 2.0
- Data models scaffolding

## โš–๏ธ License

Create Cohere Connector is open source software licensed as Apache 2.0.