forked from Rockachopa/Timmy-time-dashboard
This commit introduces the initial integration of the ResearchOrchestrator with the Paperclip task runner. It includes a new module with a client for the Paperclip API, a poller for running research tasks, and a that uses a research pipeline to generate a report and create Gitea issues. Fixes #978
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""Tools for the research pipeline."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import os
|
|
from typing import Any
|
|
|
|
from config import settings
|
|
from serpapi import GoogleSearch
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def google_web_search(query: str) -> str:
|
|
"""Perform a Google search and return the results."""
|
|
if "SERPAPI_API_KEY" not in os.environ:
|
|
logger.warning("SERPAPI_API_KEY not set, skipping web search")
|
|
return ""
|
|
params = {
|
|
"q": query,
|
|
"api_key": os.environ["SERPAPI_API_KEY"],
|
|
}
|
|
search = GoogleSearch(params)
|
|
results = search.get_dict()
|
|
return str(results)
|
|
|
|
|
|
def get_llm_client() -> Any:
|
|
"""Get an LLM client."""
|
|
# This is a placeholder. In a real application, this would return
|
|
# a client for an LLM service like OpenAI, Anthropic, or a local
|
|
# model.
|
|
class MockLLMClient:
|
|
async def completion(self, prompt: str, max_tokens: int) -> Any:
|
|
class MockCompletion:
|
|
def __init__(self, text: str) -> None:
|
|
self.text = text
|
|
|
|
return MockCompletion(f"This is a summary of the search results for '{prompt}'.")
|
|
|
|
return MockLLMClient()
|