Browse Source

Minor refactor

Remove message and combine types to chat.

Also use correct package name.
master
TheoryOfNekomata 1 year ago
parent
commit
b256052705
5 changed files with 17 additions and 18 deletions
  1. +2
    -2
      package.json
  2. +13
    -1
      src/platforms/openai/chat.ts
  3. +1
    -2
      src/platforms/openai/features/chat-completion.ts
  4. +1
    -1
      src/platforms/openai/index.ts
  5. +0
    -12
      src/platforms/openai/message.ts

+ 2
- 2
package.json View File

@@ -1,5 +1,5 @@
{
"name": "openai-utils",
"name": "@modal-sh/mio-ai",
"version": "0.0.0",
"files": [
"dist",
@@ -34,7 +34,7 @@
"test": "vitest"
},
"private": false,
"description": "Custom wrapper for OpenAI API.",
"description": "Many-in-one AI client.",
"repository": {
"url": "https://code.modal.sh/modal-soft/openai-utils",
"type": "git"


+ 13
- 1
src/platforms/openai/chat.ts View File

@@ -1,5 +1,17 @@
import Handlebars from 'handlebars';
import { Message, MessageRole } from './message';

export enum MessageRole {
SYSTEM = 'system',
USER = 'user',
ASSISTANT = 'assistant',
}

export interface MessageObject {
role: MessageRole;
content: string;
}

export type Message = string | MessageObject;

const isValidMessageObject = (maybeMessage: unknown): maybeMessage is Message => {
if (typeof maybeMessage !== 'object') {


+ 1
- 2
src/platforms/openai/features/chat-completion.ts View File

@@ -7,9 +7,8 @@ import {
PlatformResponse,
UsageMetadata,
} from '../common';
import { Message, MessageObject } from '../message';
import { ChatCompletionModel } from '../models';
import { normalizeChatMessage } from '../chat';
import { normalizeChatMessage, Message, MessageObject } from '../chat';

export interface CreateChatCompletionParams {
messages: Message | Message[];


+ 1
- 1
src/platforms/openai/index.ts View File

@@ -1,6 +1,6 @@
import { Configuration } from './common';

export * from './message';
export * from './chat';
export * from './models';
export * from './common';
export { PlatformEventEmitter, PlatformEventEmitterImpl } from './events';


+ 0
- 12
src/platforms/openai/message.ts View File

@@ -1,12 +0,0 @@
export enum MessageRole {
SYSTEM = 'system',
USER = 'user',
ASSISTANT = 'assistant',
}

export interface MessageObject {
role: MessageRole;
content: string;
}

export type Message = string | MessageObject;

Loading…
Cancel
Save