pdf_gemini
이 패키지는 Google Gemini를 사용하여 PDF 파일과 간단하게 상호작용하고 채팅할 수 있는 방법을 제공합니다.
- 스타
- 3
- 포크
- 3
- 최근 푸시(UTC)
- 2025. 5. 28.
- 프로젝트 상태
- 활성
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Pdf Gemini Package
This package provides a simple way to interact, chat with pdf files using google gemini and managing uploaded files.
Features
- Upload PDF to gemini
- Prompt PDF ang get generated response with Google Gemini Api
- Lightweight and easy to integrate into any Flutter app.
Installation
Run the command on your command prompt
flutter pub add pdf_gemini
Usage
Step 1: Import the Package
In your Dart file, import the package:
import 'package:pdf_gemini/pdf_gemini.dart';
Step 2: Provide Your API Key
When using the API service, instantiate the service class and pass your API key to it. Here's an example of how to fetch data from an API endpoint:
void main() async {
const geminiApiKey = 'your_api_key_here';
final genaiService = GenaiClient(geminiApiKey: geminiApiKey);
try {
final testFile = File('');
final data = await genaiService.promptDocument(
'file_name',
'pdf',
testFile.readAsBytesSync(),
'Your prompt',
);
print(data.text);
} catch (e) {
print('Error: $e');
}
}
Example Explained:
- Replace
'your_api_key_here'with your actual API key provided by the service you're integrating. - The
promptDocument()method accepts the document and prompt input and returns the generated response as a model (text: text, citations: sources) if successful. - Make sure to handle exceptions in case of a failed request.
Testing
To ensure your package works as expected, you can write tests to mock API responses. Here's a simple test example:
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:pdf_gemini/pdf_gemini.dart';
void main() {
group('PDFChatClient', () {
const geminiApiKey = '';
final genaiService = GenaiClient(geminiApiKey: geminiApiKey);
test('Prompt PDF Test', () async {
// Create a temporary test file
final testFile = File('your_file_path').readAsBytesSync();
try {
await genaiService.promptDocument(
fileName: 'Your file name',
fileType: 'pdf',
fileData: testFile,
prompt: 'your prompt',
model: 'gemini-1.5-flash',
);
} catch (e) {
fail('Failed: $e');
}
});
});
}
Contributing
Contributions are welcome! If you'd like to improve this package, feel free to fork the repository and submit a pull request. Make sure to write tests for any new features.
License
This project is licensed under the BSD 3-clause license - see the LICENSE file for details.
분류
사용 중인 의존성
의존성 목록 4 개
- flutter
{"sdk":"flutter"} - dio
^5.7.0 - flutter_test개발 의존성
{"sdk":"flutter"} - flutter_lints개발 의존성
^5.0.0
프로젝트에 맞는 저장소를 선택하려면?
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
- 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
- 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
- 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.
출처 및 관리
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗