diff --git a/py/packages/genkit-anthropic/README.md b/py/packages/genkit-anthropic/README.md index 43dd29bc49..ce947060af 100644 --- a/py/packages/genkit-anthropic/README.md +++ b/py/packages/genkit-anthropic/README.md @@ -5,7 +5,30 @@ > > **Preview** — This plugin is in preview and may have API changes in future releases. -This Genkit plugin provides a set of tools and utilities for working with Anthropic. +Anthropic Claude model provider for Genkit. + +## Installation + +```bash +uv add genkit-anthropic +``` + +## Usage + +```python +from genkit import Genkit +from genkit_anthropic import Anthropic + +ai = Genkit(plugins=[Anthropic()]) + +res = await ai.generate( + model='anthropic/claude-sonnet-4-6', + prompt='Explain recursion in 10 words.', +) +print(res.text) +``` + +Set `ANTHROPIC_API_KEY` in the environment, or pass `api_key=` to `Anthropic()`. ## Disclaimer diff --git a/py/packages/genkit-anthropic/pyproject.toml b/py/packages/genkit-anthropic/pyproject.toml index a26174af15..b0f6a537a9 100644 --- a/py/packages/genkit-anthropic/pyproject.toml +++ b/py/packages/genkit-anthropic/pyproject.toml @@ -62,7 +62,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-anthropic/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-django/README.md b/py/packages/genkit-django/README.md index 1b0b668393..0e40e5b0c1 100644 --- a/py/packages/genkit-django/README.md +++ b/py/packages/genkit-django/README.md @@ -1,11 +1,11 @@ # Genkit Django Plugin -`genkit-plugin-django` exposes Genkit flows as HTTP endpoints in a Django application. It mirrors `genkit-plugin-flask` and `genkit-plugin-fastapi`: one decorator turns a `@ai.flow()` into a Django view that speaks the Genkit HTTP protocol (JSON envelope, optional SSE streaming, structured error responses). +`genkit-django` exposes Genkit flows as HTTP endpoints in a Django application. It mirrors `genkit-flask` and `genkit-fastapi`: one decorator turns a `@ai.flow()` into a Django view that speaks the Genkit HTTP protocol (JSON envelope, optional SSE streaming, structured error responses). ## Install ```bash -pip install genkit-plugin-django +uv add genkit-django ``` ## Usage diff --git a/py/packages/genkit-django/pyproject.toml b/py/packages/genkit-django/pyproject.toml index 4b06c640e5..7d6fb1d4c1 100644 --- a/py/packages/genkit-django/pyproject.toml +++ b/py/packages/genkit-django/pyproject.toml @@ -67,7 +67,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-django/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-evaluators/README.md b/py/packages/genkit-evaluators/README.md index d1970d1ec1..b928f9e5f2 100644 --- a/py/packages/genkit-evaluators/README.md +++ b/py/packages/genkit-evaluators/README.md @@ -11,30 +11,34 @@ No LLM or API keys required. ## Installation ```bash -pip install genkit-plugin-evaluators +uv add genkit-evaluators ``` ## Usage ```python from genkit import Genkit -from genkit_evaluators import GenkitEval - -ai = Genkit(plugins=[GenkitEval()]) - -# Run evaluation with genkit eval-flow or programmatically -evaluator = await ai.registry.resolve_evaluator('genkitEval/regex') -result = await evaluator.run( - input={ - 'dataset': [ - {'input': 'sample', 'output': 'banana', 'reference': 'ba?a?a'}, - {'input': 'sample', 'output': 'apple', 'reference': 'ba?a?a'}, - ], - 'evalRunId': 'test', - } +from genkit.evaluator import BaseDataPoint +from genkit_evaluators import register_genkit_evaluators + +ai = Genkit() +register_genkit_evaluators(ai) + +results = await ai.evaluate( + evaluator='genkitEval/regex', + dataset=[ + BaseDataPoint(input='sample', output='banana', reference='ba?a?a'), + BaseDataPoint(input='sample', output='apple', reference='ba?a?a'), + ], ) ``` +Or from the CLI: + +```bash +genkit eval:run datasets/example.json --evaluators=genkitEval/regex +``` + ## Evaluators - **genkitEval/regex** – Reference is a regex string. Output (stringified if needed) must match. diff --git a/py/packages/genkit-evaluators/pyproject.toml b/py/packages/genkit-evaluators/pyproject.toml index 5ea0274623..e3c35b742d 100644 --- a/py/packages/genkit-evaluators/pyproject.toml +++ b/py/packages/genkit-evaluators/pyproject.toml @@ -41,8 +41,10 @@ requires-python = ">=3.10" version = "0.9.0" [project.urls] -"Homepage" = "https://github.com/genkit-ai/genkit" -"Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" +"Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" +"Documentation" = "https://firebase.google.com/docs/genkit" +"Homepage" = "https://github.com/genkit-ai/genkit" +"Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" [build-system] build-backend = "hatchling.build" diff --git a/py/packages/genkit-fastapi/README.md b/py/packages/genkit-fastapi/README.md index 5ea483add0..3d6a875b42 100644 --- a/py/packages/genkit-fastapi/README.md +++ b/py/packages/genkit-fastapi/README.md @@ -1,34 +1,118 @@ # Genkit FastAPI Plugin -Serve Genkit flows as FastAPI endpoints. +Expose Genkit flows and agents as HTTP endpoints in a FastAPI application. ## Installation ```bash -pip install genkit-plugin-fastapi +uv add genkit-fastapi genkit-google-genai ``` ## Usage +### Serving Flows (`serve_flow`) + +Use `serve_flow` to register a Genkit flow as a FastAPI endpoint: + +```python from fastapi import FastAPI from genkit import Genkit -from genkit_fastapi import genkit_fastapi_handler +from genkit_fastapi import serve_flow from genkit_google_genai import GoogleAI -ai = Genkit(plugins=[GoogleAI()]) +ai = Genkit(plugins=[GoogleAI()], model='googleai/gemini-flash-latest') app = FastAPI() +@ai.tool(description='Get current weather for a location') +async def get_weather(location: str) -> str: + return f'Sunny in {location}' + + @ai.flow() async def chat_flow(prompt: str) -> str: - response = await ai.generate(prompt=prompt) + response = await ai.generate( + prompt=prompt, + tools=[get_weather], + ) return response.text -@app.post('/chat') +# Mount flow endpoint at POST /api/chat_flow +app.include_router(serve_flow(chat_flow), prefix='/api') +``` + +### Serving Agents (`serve_agent`) + +Use `serve_agent` to expose an agent as FastAPI routes (including `/getSnapshot` and `/abort` endpoints when session state storage is enabled): + +```python +from fastapi import FastAPI +from genkit import Genkit +from genkit_fastapi import serve_agent +from genkit_google_genai import GoogleAI + +ai = Genkit(plugins=[GoogleAI()], model='googleai/gemini-flash-latest') +app = FastAPI() + + +@ai.tool(description='Get current weather for a location') +async def get_weather(location: str) -> str: + return f'Sunny in {location}' + + +weather_agent = ai.define_agent( + name='weatherAgent', + model='googleai/gemini-flash-latest', + system='You are a helpful weather assistant.', + tools=[get_weather], +) + +# Mount agent turn route at POST /api/weatherAgent (plus /getSnapshot and /abort companion endpoints) +app.include_router(serve_agent(weather_agent), prefix='/api') +``` + +### Custom Base Path & Dependency Injection + +Customize the base path or resolve request context using FastAPI's dependency injection system: + +```python +from fastapi import Depends, Header +from genkit_fastapi import serve_flow + + +async def user_context(authorization: str = Header(...)): + return {'uid': parse_token(authorization)} + + +app.include_router( + serve_flow( + chat_flow, + base_path='/chat', + context_dependency=user_context, + ), + prefix='/api', +) +``` + +### Decorator Handler (`genkit_fastapi_handler`) + +For custom route definitions, you can also use `@genkit_fastapi_handler`: + +```python +from genkit_fastapi import genkit_fastapi_handler + + +@app.post('/custom-chat', response_model=None) @genkit_fastapi_handler(ai) -async def chat(): - return chat_flow +@ai.flow() +async def custom_chat(prompt: str) -> str: + response = await ai.generate( + prompt=prompt, + tools=[get_weather], + ) + return response.text +``` ## Running @@ -42,10 +126,10 @@ uvicorn main:app ## Streaming -The handler automatically supports streaming when the client sends `Accept: text/event-stream`: +Endpoints automatically support streaming when the client sends `Accept: text/event-stream` or specifies `?stream=true`: ```bash -curl -X POST http://localhost:8000/chat \ +curl -X POST http://localhost:8000/api/chat_flow \ -H "Content-Type: application/json" \ -H "Accept: text/event-stream" \ -d '{"data": "Tell me a joke"}' diff --git a/py/packages/genkit-fastapi/pyproject.toml b/py/packages/genkit-fastapi/pyproject.toml index 0276b9ccc0..1fda37db25 100644 --- a/py/packages/genkit-fastapi/pyproject.toml +++ b/py/packages/genkit-fastapi/pyproject.toml @@ -56,7 +56,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -"Changelog" = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-fastapi/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-flask/README.md b/py/packages/genkit-flask/README.md index 8e63b55eef..129934e8be 100644 --- a/py/packages/genkit-flask/README.md +++ b/py/packages/genkit-flask/README.md @@ -1,3 +1,31 @@ -# Genkit Flask plugin +# Genkit Flask Plugin -This Genkit plugin provides a set of tools and utilities for working with Flask. +Expose Genkit flows as HTTP endpoints in a Flask application. + +## Installation + +```bash +uv add genkit-flask genkit-google-genai +``` + +## Usage + +```python +from flask import Flask +from genkit import Genkit +from genkit_flask import genkit_flask_handler +from genkit_google_genai import GoogleAI + +app = Flask(__name__) +ai = Genkit(plugins=[GoogleAI()], model='googleai/gemini-flash-latest') + + +@app.post('/api/greet') +@genkit_flask_handler(ai) +@ai.flow() +async def greet_user(name: str) -> str: + res = await ai.generate(prompt=f'Say hello to {name} in one sentence.') + return res.text +``` + +Requires Flask 3.1+. diff --git a/py/packages/genkit-flask/pyproject.toml b/py/packages/genkit-flask/pyproject.toml index 7412fed5f7..269be6e22c 100644 --- a/py/packages/genkit-flask/pyproject.toml +++ b/py/packages/genkit-flask/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ "pydantic>=2.10.5", "flask>=3.1.3", ] -description = "Genkit Firebase Plugin" +description = "Genkit Flask Plugin" keywords = [ "genkit", "ai", @@ -68,7 +68,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-flask/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-google-cloud/README.md b/py/packages/genkit-google-cloud/README.md index 3e62320344..570a2c3593 100644 --- a/py/packages/genkit-google-cloud/README.md +++ b/py/packages/genkit-google-cloud/README.md @@ -1,4 +1,23 @@ -# Google Cloud Plugin +# Genkit Google Cloud Plugin -This Genkit plugin provides a set of tools and utilities for working with Google -Cloud. +Export Genkit telemetry to Google Cloud Trace, Cloud Monitoring, and Cloud Logging. + +## Installation + +```bash +uv add genkit-google-cloud genkit-google-genai +``` + +## Usage + +```python +from genkit import Genkit +from genkit_google_cloud import enable_google_cloud_telemetry +from genkit_google_genai import GoogleAI + +enable_google_cloud_telemetry(project_id='my-project') + +ai = Genkit(plugins=[GoogleAI()], model='googleai/gemini-flash-latest') +``` + +Requires Google Cloud Application Default Credentials (ADC) or explicit credentials. diff --git a/py/packages/genkit-google-cloud/pyproject.toml b/py/packages/genkit-google-cloud/pyproject.toml index e8a48aed7c..ffcfaa0721 100644 --- a/py/packages/genkit-google-cloud/pyproject.toml +++ b/py/packages/genkit-google-cloud/pyproject.toml @@ -70,7 +70,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-google-cloud/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-google-genai/README.md b/py/packages/genkit-google-genai/README.md index 16414ff408..b2668a04dd 100644 --- a/py/packages/genkit-google-genai/README.md +++ b/py/packages/genkit-google-genai/README.md @@ -5,9 +5,7 @@ This Genkit plugin provides a unified interface for Google AI (Gemini) and Verte ## Setup environment ```bash -uv venv -source .venv/bin/activate -pip install genkit-plugins-google-genai +uv add genkit genkit-google-genai ``` ## Configuration @@ -32,7 +30,7 @@ gcloud auth application-default login ### Dynamic Models -The plugin automatically discovers available models from the API upon initialization. You can use any model name supported by the API (e.g., `googleai/gemini-2.0-flash-exp`, `vertexai/gemini-1.5-pro`). +The plugin automatically discovers available models from the API upon initialization. You can use any model name supported by the API (e.g., `googleai/gemini-flash-latest`, `vertexai/gemini-2.5-pro`). ### Dynamic Configuration @@ -47,40 +45,13 @@ config = GeminiConfigSchema.model_validate({ }) ``` -### Vertex AI Rerankers - -The VertexAI plugin provides semantic rerankers for improving RAG quality by re-scoring documents based on relevance: - -```python -from genkit import Genkit -from genkit_google_genai import VertexAI - -ai = Genkit(plugins=[VertexAI(project='my-project')]) - -# Rerank documents after retrieval -ranked_docs = await ai.rerank( - reranker='vertexai/semantic-ranker-default@latest', - query='What is machine learning?', - documents=retrieved_docs, - options={'top_n': 5}, -) -``` - -**Supported Models:** - -| Model | Description | -|-------|-------------| -| `semantic-ranker-default@latest` | Latest default semantic ranker | -| `semantic-ranker-default-004` | Semantic ranker version 004 | -| `semantic-ranker-fast-004` | Fast variant (lower latency) | - ### Vertex AI Evaluators Built-in evaluators for assessing model output quality. Evaluators are automatically registered when using the VertexAI plugin and are accessed via `ai.evaluate()`: ```python from genkit import Genkit -from genkit._core.typing import BaseDataPoint +from genkit.evaluator import BaseDataPoint from genkit_google_genai import VertexAI ai = Genkit(plugins=[VertexAI(project='my-project')]) @@ -104,22 +75,22 @@ for result in results.root: ``` -**Supported Metrics:** +**Supported evaluators:** -| Metric | Description | -|--------|-------------| -| `BLEU` | Translation quality (compare to reference) | -| `ROUGE` | Summarization quality | -| `FLUENCY` | Language mastery and readability | -| `SAFETY` | Harmful/inappropriate content detection | -| `GROUNDEDNESS` | Hallucination detection | -| `SUMMARIZATION_QUALITY` | Overall summarization ability | +| Evaluator | Description | +|-----------|-------------| +| `vertexai/bleu` | Translation quality (compare to reference) | +| `vertexai/rouge` | Summarization quality | +| `vertexai/fluency` | Language mastery and readability | +| `vertexai/safety` | Harmful/inappropriate content detection | +| `vertexai/groundedness` | Hallucination detection | +| `vertexai/summarization_quality` | Overall summarization ability | ## Examples For comprehensive usage examples, see: -- [`py/samples/google-genai-media/README.md`](../../samples/google-genai-media/README.md) - Speech, image, and video generation -- [`py/samples/gemini-code-execution/README.md`](../../samples/gemini-code-execution/README.md) - Gemini code execution -- [`py/samples/gemini-context-caching/README.md`](../../samples/gemini-context-caching/README.md) - Context caching for large prompts -- [`py/samples/vertexai-imagen/README.md`](../../samples/vertexai-imagen/README.md) - Vertex AI Imagen generation +- [google-genai-media](https://github.com/genkit-ai/genkit/tree/main/py/samples/google-genai-media) - Speech, image, and video generation +- [gemini-code-execution](https://github.com/genkit-ai/genkit/tree/main/py/samples/gemini-code-execution) - Gemini code execution +- [gemini-context-caching](https://github.com/genkit-ai/genkit/tree/main/py/samples/gemini-context-caching) - Context caching for large prompts +- [vertexai-imagen](https://github.com/genkit-ai/genkit/tree/main/py/samples/vertexai-imagen) - Vertex AI Imagen generation diff --git a/py/packages/genkit-google-genai/pyproject.toml b/py/packages/genkit-google-genai/pyproject.toml index 9e37ffdd84..d3274b8841 100644 --- a/py/packages/genkit-google-genai/pyproject.toml +++ b/py/packages/genkit-google-genai/pyproject.toml @@ -70,7 +70,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-google-genai/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-middleware/README.md b/py/packages/genkit-middleware/README.md index 353bac5b0f..610b61e772 100644 --- a/py/packages/genkit-middleware/README.md +++ b/py/packages/genkit-middleware/README.md @@ -1,6 +1,6 @@ # Genkit Middleware Plugin -A collection of middleware implementations for Firebase Genkit Python. +A collection of middleware implementations for Genkit Python. ## Overview @@ -19,9 +19,10 @@ Import the middleware classes you need and pass instances directly into `use=[]` ```python from genkit import Genkit +from genkit_google_genai import GoogleAI from genkit_middleware import Retry, Fallback, Middleware -ai = Genkit(plugins=[Middleware()]) +ai = Genkit(plugins=[GoogleAI(), Middleware()]) response = await ai.generate( model='googleai/gemini-flash-latest', @@ -38,7 +39,7 @@ These pre-packaged middlewares will be available to play with in the Dev UI by d ## Installation ```bash -pip install genkit-plugin-middleware +uv add genkit-middleware genkit-google-genai ``` ## Usage @@ -79,7 +80,7 @@ fallback = Fallback( ) response = await ai.generate( - model='googleai/gemini-2.5-ultra', + model='googleai/gemini-pro-latest', prompt='Hello!', use=[fallback], ) @@ -90,17 +91,29 @@ response = await ai.generate( Requires approval before executing tools (useful for sensitive operations): ```python +from pydantic import BaseModel, Field + from genkit import restart_tool from genkit_middleware import ToolApproval + +class DeleteInput(BaseModel): + name: str = Field(description='Database name to delete') + + +@ai.tool() +async def delete_database(input: DeleteInput) -> str: + return f'Deleted {input.name}' + + approval = ToolApproval( allowed_tools=['get_weather', 'search'], # These tools run without approval ) -response = await ai.generate( +first = await ai.generate( model='googleai/gemini-flash-latest', prompt='Delete the database', - tools=[delete_database_tool], + tools=['delete_database'], use=[approval], ) ``` @@ -109,18 +122,11 @@ When a non-allowed tool is called, execution is interrupted. Approve and re-run tool by restarting it with ``resumed_metadata`` that includes ``tool_approved``: ```python -first = await ai.generate( - model='googleai/gemini-flash-latest', - prompt='Delete the database', - tools=[delete_database_tool], - use=[approval], -) - response = await ai.generate( model='googleai/gemini-flash-latest', prompt='Delete the database', messages=list(first.messages), - tools=[delete_database_tool], + tools=['delete_database'], use=[approval], resume_restart=restart_tool( interrupt=first.interrupts[0], @@ -183,3 +189,29 @@ Provides four tools: - `read_file`: Read file content - `write_file`: Write to a file (requires `allow_write_access=True`) - `edit_file`: Edit file with string replacements (requires `allow_write_access=True`) + +### Artifacts + +Exposes `read_artifact` / `write_artifact` tools and lists session artifacts in the +system prompt. Intended for agent sessions: + +```python +from genkit_middleware import Artifacts, Middleware + +from genkit import Genkit +from genkit.agent import InMemorySessionStore +from genkit_google_genai import GoogleAI + +ai = Genkit(plugins=[GoogleAI(), Middleware()]) + +agent = ai.define_agent( + name='workspaceAgent', + model='googleai/gemini-flash-latest', + use=[Artifacts()], + store=InMemorySessionStore(), +) + +chat = agent.chat() +await chat.send('Write poem.txt with a short poem about Python agents.') +# chat.artifacts now includes poem.txt +``` diff --git a/py/packages/genkit-ollama/README.md b/py/packages/genkit-ollama/README.md index d63b55341c..b66e5c4290 100644 --- a/py/packages/genkit-ollama/README.md +++ b/py/packages/genkit-ollama/README.md @@ -49,8 +49,8 @@ print(len(embeddings[0].embedding)) These snippets assume an async context (`await` inside an `async def`); pasting them at module top level raises `SyntaxError: 'await' outside function`. See the -[runnable sample](../../samples/ollama-sample) for a complete `async def main()` -plus `ai.run_main(...)` entry point. +[runnable sample](https://github.com/genkit-ai/genkit/tree/main/py/samples/ollama-sample) +for a complete `async def main()` plus `ai.run_main(...)` entry point. ### Streaming @@ -168,7 +168,7 @@ with the URL it tried. Start the daemon (`ollama serve`) or set ## Sample -See [`py/samples/ollama-sample`](../../samples/ollama-sample) for a runnable sample covering +See [py/samples/ollama-sample](https://github.com/genkit-ai/genkit/tree/main/py/samples/ollama-sample) for a runnable sample covering chat, streaming, tool calling, and embeddings with a local Ollama server. ## Notes diff --git a/py/packages/genkit-openai/README.md b/py/packages/genkit-openai/README.md index acb21ebc16..34b6f6d5b3 100644 --- a/py/packages/genkit-openai/README.md +++ b/py/packages/genkit-openai/README.md @@ -1,8 +1,29 @@ -# OpenAI API Compatible model provider Plugin +# Genkit OpenAI Plugin -> **Community Plugin** — This plugin is community-maintained and is not an -> official Google or OpenAI product. It is provided on an "as-is" basis. -> > **Preview** — This plugin is in preview and may have API changes in future releases. -This Genkit plugin provides a set of tools and utilities for working with OpenAI. +OpenAI-compatible model provider for Genkit (OpenAI, Azure OpenAI, and other +compatible endpoints). + +## Installation + +```bash +uv add genkit-openai +``` + +## Usage + +```python +from genkit import Genkit +from genkit_openai import OpenAI + +ai = Genkit(plugins=[OpenAI()]) + +res = await ai.generate( + model='openai/gpt-5.2', + prompt='Suggest 2 catchy names for an AI newsletter.', +) +print(res.text) +``` + +Set `OPENAI_API_KEY` in the environment, or pass `api_key=` to `OpenAI()`. diff --git a/py/packages/genkit-openai/pyproject.toml b/py/packages/genkit-openai/pyproject.toml index 8c230cf526..34d28f5d7f 100644 --- a/py/packages/genkit-openai/pyproject.toml +++ b/py/packages/genkit-openai/pyproject.toml @@ -62,7 +62,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-openai/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit-vertexai/README.md b/py/packages/genkit-vertexai/README.md index 36791583ea..7c43b6ffa4 100644 --- a/py/packages/genkit-vertexai/README.md +++ b/py/packages/genkit-vertexai/README.md @@ -1,4 +1,28 @@ -# Google Cloud Vertex AI Plugin +# Genkit Vertex AI Plugin -This Genkit plugin provides a set of tools and utilities for working with Google -Cloud Vertex AI. +Integrate Genkit with Google Cloud Vertex AI Model Garden. + +## Installation + +```bash +uv add genkit-vertexai +``` + +## Usage + +```python +from genkit import Genkit +from genkit_vertexai.model_garden import ModelGarden + +ai = Genkit( + plugins=[ModelGarden(project_id='my-project', location='us-central1')], +) + +res = await ai.generate( + model='modelgarden/anthropic/claude-3-5-sonnet-v2@20241022', + prompt='Explain recursion in 10 words.', +) +print(res.text) +``` + +Requires Google Cloud Application Default Credentials (ADC) or explicit credentials. diff --git a/py/packages/genkit-vertexai/pyproject.toml b/py/packages/genkit-vertexai/pyproject.toml index 3ad65e0f5b..920314402c 100644 --- a/py/packages/genkit-vertexai/pyproject.toml +++ b/py/packages/genkit-vertexai/pyproject.toml @@ -74,7 +74,6 @@ version = "0.9.0" [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -Changelog = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit-vertexai/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py" diff --git a/py/packages/genkit/README.md b/py/packages/genkit/README.md index 5b0568dbf1..8f756cac29 100644 --- a/py/packages/genkit/README.md +++ b/py/packages/genkit/README.md @@ -11,8 +11,7 @@ you can use Genkit independently of any Google services. ## Setup Instructions ```bash -pip install genkit -pip install genkit-plugin-google-genai +uv add genkit genkit-google-genai ``` @@ -23,7 +22,7 @@ from genkit_google_genai import GoogleAI ai = Genkit( plugins=[GoogleAI()], - model='googleai/gemini-2.0-flash', + model='googleai/gemini-flash-latest', ) diff --git a/py/packages/genkit/pyproject.toml b/py/packages/genkit/pyproject.toml index 8f47919d3f..adf53fbefb 100644 --- a/py/packages/genkit/pyproject.toml +++ b/py/packages/genkit/pyproject.toml @@ -89,7 +89,6 @@ vertex-ai = ["genkit-vertexai"] [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit/issues" -"Changelog" = "https://github.com/genkit-ai/genkit/blob/main/py/packages/genkit/CHANGELOG.md" "Documentation" = "https://firebase.google.com/docs/genkit" "Homepage" = "https://github.com/genkit-ai/genkit" "Repository" = "https://github.com/genkit-ai/genkit/tree/main/py"