Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the RAG Collection in Python code #13

Open
MaxaAI opened this issue Feb 18, 2024 · 1 comment
Open

How to use the RAG Collection in Python code #13

MaxaAI opened this issue Feb 18, 2024 · 1 comment

Comments

@MaxaAI
Copy link

MaxaAI commented Feb 18, 2024

I tryed using Rag Collection in the Python Code but couldn't figure out how to make it inside of the code

import gradientai
import os
from gradientai import Gradient

os.environ['GRADIENT_ACCESS_TOKEN'] = ""
os.environ['GRADIENT_WORKSPACE_ID'] =""

Initialize your Gradient instance

gradient = Gradient()

Initialize your Gradient instance

gradient = Gradient()

def run_answer_example_with_rag_collection(*, gradient: Gradient) -> None:
question = "What is Mprofy?"

print("==== Q & A ====")
print(f"Question: {question}\n")

print("Answering question using RAG collection...")
try:
    # Assuming the RAG Collection ID is passed as a separate parameter, 
    # which is not shown in the documentation snippet provided.
    result = gradient.answer(
        question=question,
        RAG_Collections="Rag collection Id"  # Speculative parameter
    )

    print(f"Answer: {result['answer']}")
except TypeError as e:
    print(f"An error occurred: {e}")
print("================\n")

Run the function

run_answer_example_with_rag_collection(gradient=gradient)

This is the code i have tryed but i couldn't bring it working

@uts58
Copy link

uts58 commented Mar 21, 2024

Hey @MaxaAI, did you figure it out? I'm also having the same issue but can't find any docs about how to use RAG with API!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants