Skip to content

Commit

Permalink
Make dependencies flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
walsha2 committed May 27, 2023
1 parent 8a8ef18 commit d4ee12e
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.4.1

* Make dependencies flexible

## 0.4.0

* Update to latest `openapi_spec` package
Expand Down
1 change: 0 additions & 1 deletion example/pinecone_example.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ignore_for_file: unused_local_variable, avoid_print

import 'dart:io';
import 'package:pinecone/pinecone.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/pinecone.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Pinecone API client library for Dart
library pinecone;

export 'src/generated/client/client.dart';
export 'src/generated/client.dart';
export 'src/generated/schema/schema.dart';
export 'src/extensions.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'dart:io';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/retry.dart';
import '../schema/schema.dart';
import 'schema/schema.dart';

/// Enum of HTTP methods
enum HttpMethod { get, put, post, delete, options, head, patch, trace }
Expand All @@ -21,6 +21,10 @@ enum ContentType { json, multipart, xml }
/// Enum of supported authentication types
enum AuthType { keyQuery, keyHeader, keyCookie, openId }

// ==========================================
// CLASS: PineconeClientException
// ==========================================

/// HTTP exception handler for PineconeClient
class PineconeClientException implements HttpException {
PineconeClientException({
Expand Down Expand Up @@ -68,7 +72,7 @@ class PineconeClientException implements HttpException {
/// `client`: Override HTTP client to use for requests
class PineconeClient {
PineconeClient({
required this.apiKey,
this.apiKey = '',
this.host,
http.Client? client,
}) {
Expand Down Expand Up @@ -128,8 +132,6 @@ class PineconeClient {
ContentType responseType = ContentType.json,
Object? body,
}) async {
// final timer = Stopwatch()..start();

// Override with the user provided host
if (host.isEmpty) {
host = this.host ?? '';
Expand All @@ -150,9 +152,9 @@ class PineconeClient {
// Build the request URI
Uri uri;
if (host.contains('http')) {
host = Uri.parse(host).host;
host = Uri.parse(host).authority;
} else {
host = Uri.parse(Uri.https(host).toString()).host;
host = Uri.parse(Uri.https(host).toString()).authority;
}
if (secure) {
uri = Uri.https(host, path, queryParams.isEmpty ? null : queryParams);
Expand Down Expand Up @@ -499,15 +501,15 @@ class PineconeClient {
///
/// `environment`: The region for your project. See Pinecone console
///
/// `request`: Index configuration options
///
/// `indexName`: Name of the index to operate on.
///
/// `request`: Index configuration options
///
/// `PATCH` `https://controller.{environment}.pinecone.io/databases/{indexName}`
Future<void> configureIndex({
String environment = 'us-west1-gcp-free',
required ConfigureIndexRequest request,
required String indexName,
required ConfigureIndexRequest request,
}) async {
final _ = await _request(
host: 'controller.${environment}.pinecone.io',
Expand Down
4 changes: 2 additions & 2 deletions lib/src/generated/schema/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Index with _$Index {
/// Map representation of object (not serialized)
Map<String, dynamic> toMap() {
return {
'database': database,
'status': status,
'database': database.toMap(),
'status': status.toMap(),
};
}
}
2 changes: 1 addition & 1 deletion lib/src/generated/schema/query_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class QueryRequest with _$QueryRequest {
'includeValues': includeValues,
'includeMetadata': includeMetadata,
'vector': vector,
'sparseVector': sparseVector,
'sparseVector': sparseVector?.toMap(),
'id': id,
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generated/schema/update_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class UpdateRequest with _$UpdateRequest {
return {
'id': id,
'values': values,
'sparseValues': sparseValues,
'sparseValues': sparseValues?.toMap(),
'setMetadata': setMetadata,
'namespace': namespace,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generated/schema/vector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Vector with _$Vector {
return {
'id': id,
'values': values,
'sparseValues': sparseValues,
'sparseValues': sparseValues?.toMap(),
'metadata': metadata,
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generated/schema/vector_match.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class VectorMatch with _$VectorMatch {
'id': id,
'score': score,
'values': values,
'sparseValues': sparseValues,
'sparseValues': sparseValues?.toMap(),
'metadata': metadata,
};
}
Expand Down
3 changes: 1 addition & 2 deletions oas/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ main() async {
await spec.generate(
package: 'pinecone',
destination: 'lib/src/generated/',
replace: true,
schemaOptions: SchemaGeneratorOptions(
replaceOutput: true,
includeVersion: true,
),
clientOptions: ClientGeneratorOptions(
enabled: true,
replaceOutput: true,
includeVersion: true,
),
);
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pinecone
description: Unofficial Dart client for Pinecone vector database. For more details on Pinecone, please visit https://docs.pinecone.io/docs/overview.
version: 0.4.0
version: 0.4.1
maintainer: Taza Technology LLC
repository: https://github.com/tazatechnology/pinecone
issue_tracker: https://github.com/tazatechnology/pinecone/issues
Expand All @@ -11,12 +11,12 @@ environment:
sdk: '>=3.0.0 <4.0.0'

dependencies:
http: ^1.0.0
http: ">=0.13.0 <2.0.0"
freezed_annotation: ^2.2.0
json_annotation: ^4.8.1

dev_dependencies:
openapi_spec: ^0.2.0
openapi_spec: ^0.3.1
build_runner: ^2.3.2
lints: ^2.1.0
freezed: ^2.3.4
Expand Down

0 comments on commit d4ee12e

Please sign in to comment.