chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:37:47 +08:00
commit 7653f56fed
1422 changed files with 359026 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
SERPER_API_KEY="your-api-key-here"
OPENAI_API_KEY="your-api-key-here"
+43
View File
@@ -0,0 +1,43 @@
# 100% private Agentic RAG API
This is a simple API that uses CrewAI and LitServe to create a 100% private Agentic RAG API.
## How to use
1. Clone the repo
2. Install the dependencies:
```bash
pip install crewai crewai-tools litserve
```
Download Ollama and run the following command to download the Qwen3 model:
```bash
ollama pull qwen3
```
3. Run the server:
```bash
python server.py
```
4. Run the client:
```bash
python client.py --query "What is the Qwen3?"
```
---
## 📬 Stay Updated with Our Newsletter!
**Get a FREE Data Science eBook** 📖 with 150+ essential lessons in Data Science when you subscribe to our newsletter! Stay in the loop with the latest tutorials, insights, and exclusive resources. [Subscribe now!](https://join.dailydoseofds.com)
[![Daily Dose of Data Science Newsletter](https://github.com/patchy631/ai-engineering/blob/main/resources/join_ddods.png)](https://join.dailydoseofds.com)
---
## Contribution
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
+33
View File
@@ -0,0 +1,33 @@
# client.py
import requests
import json
import argparse
import time
# replace this URL with your exposed URL from the API builder. The URL looks like this
SERVER_URL = 'http://0.0.0.0:8000'
def main():
parser = argparse.ArgumentParser(description="Send a query to the LitServe server.")
parser.add_argument("--query", type=str, required=True, help="The query text to send to the server.")
args = parser.parse_args()
payload = {
"query": args.query
}
try:
response = requests.post(f"{SERVER_URL}/predict", json=payload)
response.raise_for_status() # Raise an exception for bad status codes
result = response.json()['output']['raw']
for token in result.split():
print(token, end=" ", flush=True)
time.sleep(0.05)
# print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error sending request: {e}")
if __name__ == "__main__":
main()
+64
View File
@@ -0,0 +1,64 @@
# rename .env.example to .env and add the following:
# SERPER_API_KEY=your_serper_api_key
# OPENAI_API_KEY=your_openai_api_key
from crewai import Crew, Agent, Task, LLM
import litserve as ls
from crewai_tools import SerperDevTool
# If you'd like, you can use a local LLM as well through Ollama. Do this:
# ollama pull qwen3 in the command line.
# Uncomment the following line and also the llm=llm line in the Agents definitions.
# llm = LLM(model="ollama/qwen3")
class AgenticRAGAPI(ls.LitAPI):
def setup(self, device):
researcher_agent = Agent(
role="Researcher",
goal="Research about the user's query and generate insights",
backstory="You are a helpful assistant that can answer questions about the document.",
verbose=True,
tools=[SerperDevTool()],
# llm=llm
)
writer_agent = Agent(
role="Writer",
goal="Use the available insights to write a concise and informative response to the user's query",
backstory="You are a helpful assistant that can write a report about the user's query",
verbose=True,
# llm=llm
)
researcher_task = Task(
description="Research about the user's query and generate insights: {query}",
expected_output="A concise and informative report about the user's query",
agent=researcher_agent,
)
writer_task = Task(
description="Use the available insights to write a concise and informative response to the user's query: {query}",
expected_output="A concise and informative response to the user's query",
agent=writer_agent,
)
self.crew = Crew(
agents=[researcher_agent, writer_agent],
tasks=[researcher_task, writer_task],
verbose=True,
)
def decode_request(self, request):
return request["query"]
def predict(self, query):
return self.crew.kickoff(inputs={"query": query})
def encode_response(self, output):
return {"output": output}
if __name__ == "__main__":
api = AgenticRAGAPI()
server = ls.LitServer(api)
server.run(port=8000)