Skip to content

Commit

Permalink
chore(deps): bump version (#29)
Browse files Browse the repository at this point in the history
* chore(deps): bump dependencies

* chore: update eslint

* fix: lint
  • Loading branch information
nekomeowww authored Jan 16, 2025
1 parent 8535548 commit 90d0db0
Show file tree
Hide file tree
Showing 18 changed files with 1,385 additions and 919 deletions.
4 changes: 2 additions & 2 deletions docs/components/ui/hover-border-gradient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export function HoverBorderGradient({
duration = 1,
...props
}: React.PropsWithChildren<
{
React.HTMLAttributes<HTMLElement> & {
as?: React.ElementType
className?: string
clockwise?: boolean
containerClassName?: string
duration?: number
} & React.HTMLAttributes<HTMLElement>
}
>) {
const [hovered, setHovered] = useState<boolean>(false)
const [direction, setDirection] = useState<Direction>('TOP')
Expand Down
10 changes: 5 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@radix-ui/react-slot": "^1.1.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"framer-motion": "^11.12.0",
"framer-motion": "^11.18.0",
"fumadocs-core": "14.5.4",
"fumadocs-docgen": "^1.3.2",
"fumadocs-mdx": "11.1.2",
Expand All @@ -30,8 +30,8 @@
},
"devDependencies": {
"@types/mdx": "^2.0.13",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@xsai/embed": "workspace:^",
"@xsai/generate-object": "workspace:^",
"@xsai/generate-speech": "workspace:^",
Expand All @@ -43,8 +43,8 @@
"@xsai/stream-text": "workspace:^",
"@xsai/tool": "workspace:^",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"valibot": "catalog:",
"xsai": "workspace:^"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Config } from 'tailwindcss'

import { createPreset } from 'fumadocs-ui/tailwind-plugin'
import animate from 'tailwindcss-animate'
// @ts-expect-error missing types
import flattenColorPalette from 'tailwindcss/lib/util/flattenColorPalette'
import animate from 'tailwindcss-animate'

function addVariablesForColors({ addBase, theme }: any) {
const allColors = flattenColorPalette(theme('colors'))
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import antfu from '@antfu/eslint-config'
import ii from '@importantimport/eslint-config'

export default antfu({ typescript: true })
.append(ii({ functional: false })) as Linter.Config
.append(ii({})) as Linter.Config
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
"bump": "bumpp",
"docs:dev": "corepack pnpm -rF @xsai/docs dev",
"docs:generate-files": "corepack pnpm -rF @xsai/docs generate-files",
"lint": "eslint --flag unstable_ts_config .",
"lint:fix": "eslint --flag unstable_ts_config . --fix",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "corepack pnpm -r --workspace-concurrency=1 test"
},
"devDependencies": {
"@antfu/eslint-config": "^3.9.2",
"@importantimport/eslint-config": "1.0.0-alpha.2",
"@antfu/eslint-config": "^3.14.0",
"@importantimport/eslint-config": "^1.0.0-alpha.3",
"@importantimport/tsconfig": "^0.1.1",
"@types/eslint": "^9.6.1",
"@types/node": "^22.9.1",
"@types/node": "^22.10.7",
"automd": "^0.3.12",
"bumpp": "^9.8.1",
"eslint": "^9.15.0",
"jiti": "^2.4.0",
"pkgroll": "^2.5.1",
"bumpp": "^9.10.1",
"eslint": "^9.18.0",
"jiti": "^2.4.2",
"pkgroll": "^2.6.1",
"tsx": "^4.19.2",
"vitest": "^2.1.5"
"vitest": "^2.1.8"
}
}
2 changes: 1 addition & 1 deletion packages/embed/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { embed, embed as default, type EmbedOptions, type EmbedResponseUsage, type EmbedResult } from './utils/embed'
export { embed as default, embed, type EmbedOptions, type EmbedResponseUsage, type EmbedResult } from './utils/embed'
export { embedMany, type EmbedManyOptions, type EmbedManyResult } from './utils/embed-many'
2 changes: 1 addition & 1 deletion packages/embed/src/utils/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface EmbedResponse {
object: 'embedding'
}[]
model: string
object: 'list' | ({} & string)
object: 'list' | (string & {})
system_fingerprint?: string
usage: EmbedResponseUsage
}
Expand Down
32 changes: 16 additions & 16 deletions packages/generate-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ export interface GenerateTextResponse {
usage: Usage
}

export interface ToolCall {
args: string
toolCallId: string
toolCallType: 'function'
toolName: string
}

export interface ToolResult {
args: Record<string, unknown>
result: string
toolCallId: string
toolName: string
}

export interface GenerateTextResult {
finishReason: FinishReason
steps: StepResult[]
Expand All @@ -64,12 +50,26 @@ export interface StepResult {
usage: Usage
}

/** @internal */
type RawGenerateTextTrampoline<T> = Promise<(() => RawGenerateTextTrampoline<T>) | T>
export interface ToolCall {
args: string
toolCallId: string
toolCallType: 'function'
toolName: string
}

export interface ToolResult {
args: Record<string, unknown>
result: string
toolCallId: string
toolName: string
}

/** @internal */
type RawGenerateText = (options: GenerateTextOptions) => RawGenerateTextTrampoline<GenerateTextResult>

/** @internal */
type RawGenerateTextTrampoline<T> = Promise<(() => RawGenerateTextTrampoline<T>) | T>

/** @internal */
const rawGenerateText: RawGenerateText = async (options: GenerateTextOptions) =>
await chat({
Expand Down
2 changes: 1 addition & 1 deletion packages/generate-transcription/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
},
"devDependencies": {
"@xsai/providers": "workspace:",
"openai": "^4.76.1"
"openai": "^4.78.1"
}
}
4 changes: 2 additions & 2 deletions packages/providers/src/providers/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { generateCRO } from '../utils/generate-cro'

export const createOllama = (userOptions?: ProviderOptions<false>):
/** @see {@link https://ollama.com/search} */
ChatProvider<'gemma2' | 'llama3.1' | 'llama3.2' | 'llama3.2-vision' | 'llama3.3' | 'qwen2.5' | 'qwen2.5-coder' | 'qwq' | ({} & string)>
& EmbedProvider<'all-minilm' | 'mxbai-embed-large' | 'nomic-embed-text' | ({} & string)>
ChatProvider<'gemma2' | 'llama3.1' | 'llama3.2' | 'llama3.2-vision' | 'llama3.3' | 'qwen2.5' | 'qwen2.5-coder' | 'qwq' | (string & {})>
& EmbedProvider<'all-minilm' | 'mxbai-embed-large' | 'nomic-embed-text' | (string & {})>
& ModelProvider => {
const options: ProviderResult = {
...userOptions,
Expand Down
26 changes: 13 additions & 13 deletions packages/providers/src/types/provider.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import type { CommonRequestOptions } from '@xsai/shared'

/** T: required apiKey */
export type ProviderOptions<T extends boolean = false> =
T extends true
? Partial<Omit<ProviderResult, 'apiKey'>> & Required<Pick<ProviderResult, 'apiKey'>>
: Partial<ProviderResult>

export type ProviderResult = Omit<CommonRequestOptions, 'model'> & Partial<Pick<CommonRequestOptions, 'model'>>

export interface ChatProvider<T extends string = string> {
chat: (model: ({} & string) | T) => CommonRequestOptions
chat: (model: (string & {}) | T) => CommonRequestOptions
}

export interface EmbedProvider<T extends string = string> {
embed: (model: ({} & string) | T) => CommonRequestOptions
embed: (model: (string & {}) | T) => CommonRequestOptions
}

export interface ModelProvider {
model: () => ProviderResult
}

/** T: required apiKey */
export type ProviderOptions<T extends boolean = false> =
T extends true
? Partial<Omit<ProviderResult, 'apiKey'>> & Required<Pick<ProviderResult, 'apiKey'>>
: Partial<ProviderResult>

export type ProviderResult = Omit<CommonRequestOptions, 'model'> & Partial<Pick<CommonRequestOptions, 'model'>>

export interface SpeechProvider<T extends string = string, T2 = undefined> {
speech: T2 extends undefined
? (model: ({} & string) | T) => CommonRequestOptions
: (model: ({} & string) | T, extraOptions?: T2) => CommonRequestOptions & T2
? (model: (string & {}) | T) => CommonRequestOptions
: (model: (string & {}) | T, extraOptions?: T2) => CommonRequestOptions & T2
}

export interface TranscriptionProvider<T extends string = string> {
transcription: (model: ({} & string) | T) => CommonRequestOptions
transcription: (model: (string & {}) | T) => CommonRequestOptions
}
2 changes: 1 addition & 1 deletion packages/shared-chat/src/types/finish-reason.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | ({} & string)
export type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | (string & {})
32 changes: 16 additions & 16 deletions packages/shared-chat/src/types/message-part.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export type Part =
| AudioPart
| ImagePart
| RefusalPart
| TextPart
export interface AudioBase64 {
/**
* Base64 encoded audio data.
*/
data: string
format: 'mp3' | 'wav'
}

export interface AudioPart extends CommonPart<'input_audio'> {
input_audio: AudioBase64
}

export interface CommonPart<T extends string> {
type: T
Expand All @@ -24,17 +30,11 @@ export interface ImageURLorBase64 {
url: string
}

export interface AudioPart extends CommonPart<'input_audio'> {
input_audio: AudioBase64
}

export interface AudioBase64 {
/**
* Base64 encoded audio data.
*/
data: string
format: 'mp3' | 'wav'
}
export type Part =
| AudioPart
| ImagePart
| RefusalPart
| TextPart

export interface RefusalPart extends CommonPart<'refusal'> {
refusal: string
Expand Down
38 changes: 19 additions & 19 deletions packages/shared-chat/src/types/message.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import type { AudioPart, ImagePart, Part, RefusalPart, TextPart } from './message-part'

type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>
export interface AssistantMessage extends Optional<CommonMessage<'assistant', AssistantMessagePart>, 'content'> {
refusal?: null | string
tool_calls?: ToolCall[]
// TODO: audio
}

export type Message = AssistantMessage | SystemMessage | ToolMessage | UserMessage
export type AssistantMessagePart = RefusalPart | TextPart

export interface AssistantMessageResponse extends Omit<AssistantMessage, 'content'> {
content?: string
}

export interface CommonMessage<T extends string, P extends Part> {
content: Array<P> | string
name?: string
role: T
}

export type SystemMessagePart = TextPart
export type Message = AssistantMessage | SystemMessage | ToolMessage | UserMessage

export interface SystemMessage extends CommonMessage<'system', SystemMessagePart> {}

export type UserMessagePart = AudioPart | ImagePart | TextPart

export interface UserMessage extends CommonMessage<'user', UserMessagePart> { }

export type AssistantMessagePart = RefusalPart | TextPart
export type SystemMessagePart = TextPart

export interface ToolCall {
function: {
Expand All @@ -29,18 +33,14 @@ export interface ToolCall {
type: 'function'
}

export interface AssistantMessage extends Optional<CommonMessage<'assistant', AssistantMessagePart>, 'content'> {
refusal?: null | string
tool_calls?: ToolCall[]
// TODO: audio
}

export interface AssistantMessageResponse extends Omit<AssistantMessage, 'content'> {
content?: string
export interface ToolMessage extends Omit<CommonMessage<'tool', ToolMessagePart>, 'name'> {
tool_call_id: string
}

export type ToolMessagePart = TextPart

export interface ToolMessage extends Omit<CommonMessage<'tool', ToolMessagePart>, 'name'> {
tool_call_id: string
}
export interface UserMessage extends CommonMessage<'user', UserMessagePart> { }

export type UserMessagePart = AudioPart | ImagePart | TextPart

type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>
2 changes: 1 addition & 1 deletion packages/stream-object/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@gcornut/valibot-json-schema": "catalog:",
"@xsai/providers": "workspace:",
"best-effort-json-parser": "^1.1.2",
"type-fest": "^4.31.0",
"type-fest": "^4.32.0",
"valibot": "catalog:"
}
}
36 changes: 18 additions & 18 deletions packages/stream-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ import {
type Usage,
} from '@xsai/shared-chat'

// TODO: improve chunk type
export interface ChunkResult {
choices: {
delta: {
content: string
role: 'assistant'
}
finish_reason?: FinishReason
index: number
}[]
created: number
id: string
model: string
object: 'chat.completion.chunk'
system_fingerprint: string
usage?: Usage
}

export interface StreamTextOptions extends ChatOptions {
onChunk?: (chunk: ChunkResult) => Promise<void> | void
/** if you want to disable stream, use `@xsai/generate-{text,object}` */
Expand All @@ -26,24 +44,6 @@ export interface StreamTextResult {
usage?: Usage
}

// TODO: improve chunk type
export interface ChunkResult {
choices: {
delta: {
content: string
role: 'assistant'
}
finish_reason?: FinishReason
index: number
}[]
created: number
id: string
model: string
object: 'chat.completion.chunk'
system_fingerprint: string
usage?: Usage
}

const chunkHeaderPrefix = 'data: '
const chunkErrorPrefix = `{"error":`

Expand Down
Loading

0 comments on commit 90d0db0

Please sign in to comment.