Skip to main content

No project description provided

Project description

Relevance AI - The home of your AI Workforce

🔥 Use Relevance to build AI agents for your AI workforce:

  • ⚡ Connect your python api's to tools for Agents or custom actions for GPTs.
  • 🚀 Share your tools as AI web apps with your team to use.

Sign up for a free account ->

🧠 Documentation

Type Link
Home Page Home Page
Platform Platform
Developer Documentation Documentation

Getting Started

  1. Installation: pip install relevanceai

This example uses fastapi and uvicorn so lets install that too: pip install fastapi pip install uvicorn[standard]

  1. Create your FastAPI app - skip if you already have one Here is a quick example of a FastAPI app:
from fastapi import FastAPI
app = FastAPI()

class HelloWorldParams(BaseModel):
    message : str = Query(..., title="Message", description="message from user")

class HelloWorldResponse(BaseModel):
    reply : str

def hello_world(prompt):
    return {"reply" : "hello world"}

@app.post("/hello_world", name="Hello World", description="Reply always with hello world", response_model=HelloWorldResponse)
def hello_world_api(commons: HelloWorldParams):
    return hello_world(commons.message)
  1. Describe for your tools Make sure to give your FastAPI endpoints as much descrition as possible. These provided descriptions are utilized in the agent prompt so that the Agent can better understand your tools.

For example: Add a title and description for the inputs of your tool, explaining what they are and what kind of value to provide:

class HelloWorldParams(BaseModel):
    message : str = Query(..., description="message from user")

Add a name and description about the tool explaining when to use it and what it does:

@app.post("/hello_world", name="Hello World", description="Reply always with hello world", response_model=HelloWorldResponse)

Relevance AI will automatically take these values from your fastapi app and use it to create a prompt for the agent.

  1. Lets connect it live to Relevance AI In short all it takes to connect is to add the following lines to your app:
from relevanceai.connect.fastapi import connect_fastapi_to_rai

connect_fastapi_to_rai(app.routes, PUBLIC_URL)

Where PUBLIC_URL is the public url of your app. For example https://myapp.com.

If you are working locally and dont have a public url you can use ngrok to create a public url for your app.

  1. All together
from pyngrok import ngrok
PUBLIC_URL = ngrok.connect(8000).public_url
  1. Putting this all together
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi import APIRouter, Query
from pydantic import BaseModel
from typing import List

#create FastAPI app
app = FastAPI()
#add cors middleware to allow all origins
app.add_middleware(
    CORSMiddleware,
    allow_origins=['*'],
    allow_credentials=True,
    allow_methods=['*'],
    allow_headers=['*'],
)

class HelloWorldParams(BaseModel):
    message : str = Query(..., description="message from user")

class HelloWorldResponse(BaseModel):
    reply : str

def hello_world(prompt):
    return {"reply" : "hello world"}

@app.post(
        "/hello_world", name="Hello World", description="Reply always with hello world", response_model=HelloWorldResponse
    )
def hello_world_api(commons: HelloWorldParams):
    return hello_world(commons.message)

#If you are deploying the api from a local computer use ngrok to expose a public url.
from pyngrok import ngrok
PUBLIC_URL = ngrok.connect(8000).public_url

#This will create a Tool in Relevance AI that will call your API endpoint
from relevanceai.connect.fastapi import connect_fastapi_to_rai
connect_fastapi_to_rai(app.routes, PUBLIC_URL)

Roadmap & Contribution

More examples and api connectors coming soon. Feel free to contribute to this repo.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

relevanceai-6.0.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

relevanceai-6.0.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file relevanceai-6.0.0.tar.gz.

File metadata

  • Download URL: relevanceai-6.0.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for relevanceai-6.0.0.tar.gz
Algorithm Hash digest
SHA256 5c025ba46bcd8155bc2264529b6fa085dec512c3351186211c592f1e6222f936
MD5 e137525a8e5264766a1bb2957004f452
BLAKE2b-256 05a07648de7f620ac7b827966f3c0b442cc7f2b2397aeaa99dde7941c357654e

See more details on using hashes here.

File details

Details for the file relevanceai-6.0.0-py3-none-any.whl.

File metadata

  • Download URL: relevanceai-6.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for relevanceai-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0edde862be1e23b34b24263b6e6e8813465489eb25ac72b311c7b0076c2f04bc
MD5 6f6a2f538f96fa584cafa68db497f7a7
BLAKE2b-256 d6f8a4489c152895dca5b4b7e394250f7c8fb954fc26c3bb4a52b1622523170f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page