Skip to content

feat(ai): add Google Palm2 (Generative AI) API client - #836

Open
alic3mai10ve6dec-ops wants to merge 2 commits into
arakoodev:tsfrom
alic3mai10ve6dec-ops:feat/palm2-api
Open

alic3mai10ve6dec-ops wants to merge 2 commits into
arakoodev:tsfrom
alic3mai10ve6dec-ops:feat/palm2-api

Conversation

@alic3mai10ve6dec-ops

Copy link
Copy Markdown

Summary

Adds Palm2 class wrapping the Google Generative Language API v1beta (Palm 2 / Gemini models).

Changes

  • New class: Palm2 in lib/palm2/palm2.ts
    • Single-prompt chat (generateContent)
    • Batch chat for multiple prompts
    • Token counting (countTokens)
    • Model listing (listModels)
    • Retry with backoff for 5xx errors (uses @lifeomic/attempt)
    • API key via constructor, GOOGLE_API_KEY, or PALM2_API_KEY env vars
  • 12 unit tests in tests/palm2/palm2.test.ts
  • Updated exports in ai/src/index.ts

Design Decisions

  • Follows the same patterns as existing GeminiAI and OpenAI classes
  • Uses axios for HTTP (consistent with rest of codebase)
  • Uses @lifeomic/attempt for retry (already a dependency)
  • v1beta endpoint (current stable for Generative AI API)
  • Default model: gemini-pro

Closes #279

Adds Palm2 class wrapping the Google Generative Language API v1beta.

Features:
- Single-prompt chat (generateContent)
- Batch chat for multiple prompts
- Token counting (countTokens)
- Model listing (listModels)
- Retry with backoff for 5xx errors
- API key via constructor, GOOGLE_API_KEY, or PALM2_API_KEY

Includes 12 unit tests.

Closes arakoodev#279
@alic3mai10ve6dec-ops

Copy link
Copy Markdown
Author

I have read the Arakoo CLA Document and I hereby sign the CLA

The @lifeomic/attempt retry() takes (attemptFunc, options?) not
(attemptFunc, shouldRetry, options). Fixed to pass { delay, maxAttempts }
as the second argument.
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

Successfully merging this pull request may close these issues.

BOUNTY: add support for Google Palm2 API in javascript/typescript

1 participant