@friendliai/ai-provider 0.1.19 → 0.1.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @friendliai/ai-provider
2
2
 
3
+ ## 0.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 89b09de: Built-in tool non-streaming support
8
+
9
+ ## 0.1.20
10
+
11
+ ### Patch Changes
12
+
13
+ - 7caa63e: ## Updated code to match ai sdk 4.0.10
14
+
15
+ - createFriendliAI -> createFriendli
16
+ - Dependency Update
17
+ - Updated tool call parsing logic
18
+ - Improved object creation logic
19
+ - Added regex output support
20
+ - delete "content_filter", "function_call" finish reason
21
+
3
22
  ## 0.1.19
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -51,6 +51,25 @@ const { text } = await generateText({
51
51
  })
52
52
  ```
53
53
 
54
+ ### Example: Using Enforcing Patterns (Regex)
55
+
56
+ Specify a specific pattern (e.g., CSV), character sets, or specific language characters (e.g., Korean Hangul characters) for your LLM's output.
57
+
58
+ ```ts
59
+ import { friendli } from "@friendliai/ai-provider";
60
+ import { generateText } from "ai";
61
+
62
+ const { text } = await generateText({
63
+ model: friendli("meta-llama-3.1-8b-instruct", {
64
+ regex: "[\n ,.?!0-9\uac00-\ud7af]*",
65
+ }),
66
+ maxTokens: 40,
67
+ prompt: "who is the first king of the Joseon Dynasty?",
68
+ });
69
+
70
+ console.log(text);
71
+ ```
72
+
54
73
  ### Example: Using built-in tools (Beta)
55
74
 
56
75
  If you use `@friendliai/ai-provider`, you can use the [built-in tools](https://friendli.ai/docs/guides/serverless_endpoints/tools/built_in_tools) via the `tools` option.
@@ -84,7 +103,7 @@ FriendliAI language models can also be used in the `streamText`, `generateObject
84
103
 
85
104
  ## OpenAI Compatibility
86
105
 
87
- 🎯 We can also use `@ai-sdk/openai` with OpenAI compatibility.
106
+ We can also use `@ai-sdk/openai` with OpenAI compatibility.
88
107
 
89
108
  ```ts
90
109
  import { createOpenAI } from "@ai-sdk/openai";
package/dist/index.d.mts CHANGED
@@ -50,6 +50,10 @@ interface FriendliAIChatSettings {
50
50
  files: Array<string>;
51
51
  }>;
52
52
  /**
53
+ BETA FEATURE: You can write a regular expression to force output that satisfies that regular expression.
54
+ */
55
+ regex?: string;
56
+ /**
53
57
  A unique identifier representing your end-user, which can help FriendliAI to
54
58
  monitor and detect abuse. Learn more.
55
59
  */
@@ -72,10 +76,6 @@ interface FriendliAIProviderSettings {
72
76
  */
73
77
  baseURL?: string;
74
78
  /**
75
- @deprecated Use `baseURL` instead.
76
- */
77
- baseUrl?: string;
78
- /**
79
79
  API key for authenticating requests.
80
80
  */
81
81
  apiKey?: string;
@@ -88,12 +88,6 @@ interface FriendliAIProviderSettings {
88
88
  */
89
89
  headers?: Record<string, string>;
90
90
  /**
91
- FriendliAI compatibility mode. Should be set to `strict` when using the FriendliAI API,
92
- and `compatible` when using 3rd party providers. In `compatible` mode, newer
93
- information such as streamOptions are not being sent. Defaults to 'compatible'.
94
- */
95
- compatibility?: "strict" | "compatible";
96
- /**
97
91
  Custom fetch implementation. You can use it as a middleware to intercept requests,
98
92
  or to provide a custom fetch implementation for e.g. testing.
99
93
  */
@@ -102,11 +96,15 @@ interface FriendliAIProviderSettings {
102
96
  /**
103
97
  Create an FriendliAI provider instance.
104
98
  */
105
- declare function createFriendliAI(options?: FriendliAIProviderSettings): FriendliAIProvider;
99
+ declare function createFriendli(options?: FriendliAIProviderSettings): FriendliAIProvider;
106
100
  declare const friendli: FriendliAIProvider;
107
101
  /**
108
102
  * @deprecated Use `friendli` instead.
109
103
  */
110
104
  declare const friendliai: FriendliAIProvider;
105
+ /**
106
+ * @deprecated Use `createFriendli` instead.
107
+ */
108
+ declare const createFriendliAI: typeof createFriendli;
111
109
 
112
- export { type FriendliAIProvider, type FriendliAIProviderSettings, createFriendliAI, friendli, friendliai };
110
+ export { type FriendliAIProvider, type FriendliAIProviderSettings, createFriendli, createFriendliAI, friendli, friendliai };
package/dist/index.d.ts CHANGED
@@ -50,6 +50,10 @@ interface FriendliAIChatSettings {
50
50
  files: Array<string>;
51
51
  }>;
52
52
  /**
53
+ BETA FEATURE: You can write a regular expression to force output that satisfies that regular expression.
54
+ */
55
+ regex?: string;
56
+ /**
53
57
  A unique identifier representing your end-user, which can help FriendliAI to
54
58
  monitor and detect abuse. Learn more.
55
59
  */
@@ -72,10 +76,6 @@ interface FriendliAIProviderSettings {
72
76
  */
73
77
  baseURL?: string;
74
78
  /**
75
- @deprecated Use `baseURL` instead.
76
- */
77
- baseUrl?: string;
78
- /**
79
79
  API key for authenticating requests.
80
80
  */
81
81
  apiKey?: string;
@@ -88,12 +88,6 @@ interface FriendliAIProviderSettings {
88
88
  */
89
89
  headers?: Record<string, string>;
90
90
  /**
91
- FriendliAI compatibility mode. Should be set to `strict` when using the FriendliAI API,
92
- and `compatible` when using 3rd party providers. In `compatible` mode, newer
93
- information such as streamOptions are not being sent. Defaults to 'compatible'.
94
- */
95
- compatibility?: "strict" | "compatible";
96
- /**
97
91
  Custom fetch implementation. You can use it as a middleware to intercept requests,
98
92
  or to provide a custom fetch implementation for e.g. testing.
99
93
  */
@@ -102,11 +96,15 @@ interface FriendliAIProviderSettings {
102
96
  /**
103
97
  Create an FriendliAI provider instance.
104
98
  */
105
- declare function createFriendliAI(options?: FriendliAIProviderSettings): FriendliAIProvider;
99
+ declare function createFriendli(options?: FriendliAIProviderSettings): FriendliAIProvider;
106
100
  declare const friendli: FriendliAIProvider;
107
101
  /**
108
102
  * @deprecated Use `friendli` instead.
109
103
  */
110
104
  declare const friendliai: FriendliAIProvider;
105
+ /**
106
+ * @deprecated Use `createFriendli` instead.
107
+ */
108
+ declare const createFriendliAI: typeof createFriendli;
111
109
 
112
- export { type FriendliAIProvider, type FriendliAIProviderSettings, createFriendliAI, friendli, friendliai };
110
+ export { type FriendliAIProvider, type FriendliAIProviderSettings, createFriendli, createFriendliAI, friendli, friendliai };