Skip to content

feat: add generateAnswer() for AQA support #404

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kartikayy007
Copy link

@Kartikayy007 Kartikayy007 commented Mar 9, 2025

Resolves #80

Feature: AQA Support via generateAnswer()

What's changed

Implements the requested AQA (Attributed Question Answering) support by adding:

  • New generateAnswer() method in GenerativeModel class
  • Task.GENERATE_ANSWER enum value
  • Defined GenerateAnswerRequest and GenerateAnswerResponse interfaces
  • Updated tests

Testing

  • Verified against AQA API endpoints
  • Added comprehensive test cases

Example Usage

import {GoogleGenerativeAI} from '@google/generative-ai';

const genAI = new GoogleGenerativeAI(API_KEY);
const model = genAI.getGenerativeModel({model: 'models/aqa'});

try {
  const result = await model.generateAnswer({
    input: "What causes seasons?",
    sources: [{
      title: "NASA Earth Facts",
      content: "Earth's axial tilt causes seasonal variations..."
    }],
    temperature: 0.7
  });
  
  console.log('Answer:', result.answer);
  console.log('Confidence:', result.confidenceScore);
} catch (err) {
  console.error('AQA Error:', err);
}

Implements the generateAnswer() method to support Attributed Question Answering models.
Includes type definitions and tests.

Resolves google-gemini#80
@Kartikayy007
Copy link
Author

@IvanLH @hsubox76 Could I get your review on this AQA implementation when you have time?

@Kartikayy007
Copy link
Author

hey @hkt74 do this feature implementation seem fine?

@Annhiluc Annhiluc added type:feature request New feature request/enhancement status:triaged Issue/PR triaged to the corresponding sub-team p3 labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3 status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Where is the generateAnswer() method?
2 participants