@astrive-ai/providers 1.0.35 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './base-provider.js';
2
2
  export * from './provider-manager.js';
3
- export * from './groq-provider.js';
4
3
  export * from './openai-compatible-provider.js';
5
4
  export * from './overchat-provider.js';
6
5
  export * from './zellrayy-provider.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './base-provider.js';
2
2
  export * from './provider-manager.js';
3
- export * from './groq-provider.js';
4
3
  export * from './openai-compatible-provider.js';
5
4
  export * from './overchat-provider.js';
6
5
  export * from './zellrayy-provider.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrive-ai/providers",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './base-provider.js';
2
2
  export * from './provider-manager.js';
3
- export * from './groq-provider.js';
4
3
  export * from './openai-compatible-provider.js';
5
4
  export * from './overchat-provider.js';
6
5
  export * from './zellrayy-provider.js';
@@ -1,145 +0,0 @@
1
- import { BaseProvider } from './base-provider.js';
2
- import { ChatRequest, ChatResponse, ChatChunk, ILogger, IEventEmitter } from '@astrive-ai/types';
3
-
4
- export class GroqProvider extends BaseProvider {
5
- private baseUrl = 'https://api.groq.com/openai/v1';
6
- private models = [
7
- 'llama-3.1-8b-instant',
8
- 'llama-3.3-70b-versatile',
9
- 'llama-3.1-70b-versatile',
10
- 'mixtral-8x7b-32768',
11
- 'gemma2-9b-it'
12
- ];
13
-
14
- constructor(logger: ILogger, events: IEventEmitter) {
15
- super('groq', 'official', logger, events);
16
- }
17
-
18
- public async chat(request: ChatRequest): Promise<ChatResponse> {
19
- const url = `${this.baseUrl}/chat/completions`;
20
- const mappedMessages = request.messages.map(msg => {
21
- const mapped = { ...msg } as any;
22
- if (mapped.tool_calls) {
23
- mapped.tool_calls = mapped.tool_calls.map((tc: any) => ({
24
- id: tc.id,
25
- type: 'function',
26
- function: {
27
- name: tc.name,
28
- arguments: typeof tc.arguments === 'string' ? tc.arguments : JSON.stringify(tc.arguments)
29
- }
30
- }));
31
- }
32
- return mapped;
33
- });
34
-
35
- const payload = {
36
- messages: mappedMessages,
37
- model: request.model || this.models[0],
38
- temperature: request.temperature,
39
- max_tokens: request.maxTokens,
40
- tools: request.tools
41
- };
42
-
43
- const data = await this.fetchJSON<any>(url, {
44
- method: 'POST',
45
- headers: this.buildHeaders(),
46
- body: JSON.stringify(payload)
47
- });
48
-
49
- return {
50
- id: data.id,
51
- content: data.choices[0].message.content || '',
52
- role: 'assistant' as const,
53
- toolCalls: data.choices[0].message.tool_calls?.map((tc: any) => ({
54
- id: tc.id,
55
- name: tc.function.name,
56
- arguments: typeof tc.function.arguments === 'string' ? JSON.parse(tc.function.arguments) : tc.function.arguments
57
- })),
58
- usage: data.usage ? {
59
- promptTokens: data.usage.prompt_tokens,
60
- completionTokens: data.usage.completion_tokens,
61
- totalTokens: data.usage.total_tokens
62
- } : undefined,
63
- model: data.model,
64
- finishReason: data.choices[0].finish_reason || 'stop'
65
- };
66
- }
67
-
68
- public async *chatStream(request: ChatRequest): AsyncGenerator<ChatChunk, void, unknown> {
69
- const url = `${this.baseUrl}/chat/completions`;
70
- const mappedMessages = request.messages.map(msg => {
71
- const mapped = { ...msg } as any;
72
- if (mapped.tool_calls) {
73
- mapped.tool_calls = mapped.tool_calls.map((tc: any) => ({
74
- id: tc.id,
75
- type: 'function',
76
- function: {
77
- name: tc.name,
78
- arguments: typeof tc.arguments === 'string' ? tc.arguments : JSON.stringify(tc.arguments)
79
- }
80
- }));
81
- }
82
- return mapped;
83
- });
84
-
85
- const payload = {
86
- messages: mappedMessages,
87
- model: request.model || this.models[0],
88
- temperature: request.temperature,
89
- max_tokens: request.maxTokens,
90
- tools: request.tools,
91
- stream: true
92
- };
93
-
94
- const response = await fetch(url, {
95
- method: 'POST',
96
- headers: this.buildHeaders(),
97
- body: JSON.stringify(payload)
98
- });
99
-
100
- if (!response.ok) {
101
- throw new Error(`HTTP ${response.status}: ${await response.text()}`);
102
- }
103
-
104
- if (!response.body) throw new Error('No response body');
105
-
106
- const reader = response.body.getReader();
107
- const decoder = new TextDecoder('utf-8');
108
- let buffer = '';
109
-
110
- while (true) {
111
- const { done, value } = await reader.read();
112
- if (done) break;
113
- buffer += decoder.decode(value, { stream: true });
114
-
115
- const lines = buffer.split('\n');
116
- buffer = lines.pop() || '';
117
-
118
- const events = this.parseSSE(lines.join('\n'));
119
- for (const event of events) {
120
- const delta = event.choices?.[0]?.delta;
121
- if (delta && delta.content) {
122
- yield {
123
- content: delta.content,
124
- done: false
125
- };
126
- }
127
- if (event.choices?.[0]?.finish_reason) {
128
- yield {
129
- content: '',
130
- done: true
131
- };
132
- }
133
- }
134
- }
135
- }
136
-
137
- public getModels(): string[] {
138
- return [...this.models];
139
- }
140
-
141
- public supportsFeature(feature: string): boolean {
142
- const supported = ['chat', 'function_calling', 'streaming'];
143
- return supported.includes(feature);
144
- }
145
- }