Skip to content

Commit

Permalink
feat: Overhaul invocation parameter specification (#5228)
Browse files Browse the repository at this point in the history
* Refactor invocation parameter processing

* Fix miport

* Rename validation function

* Update graphql schema

* Update type annotation to union type

* Add base class to union type

* Update gql schema

* Use strawberry interface

* refactor: Render invocation parameters form using data from api (#5165)

* refactor: Render invocation parameters form using data from api

* Map model invocation parameters to invocation parameter inputs

* Fail gracefully when parsing invocation params in ui

* Improve regist

* Update gql schema and supported invocation parameters query

* Set default to modelName

* Add canonical name to invocation parameter input

* Merge similar invocation parameters across providers, if possible, when switching providers

* Fix construct_invocation_parameters method

* Update invocation parameters for supported models

* Allow canonical name to be unset

* Use correct import

* Use None for canonical types

* Remove stop sequence support from o1 preview models

* Bump generated gql types

* Remove redundant invocation parameters from input

* Fix type annotations

* Fix type issues and regenerate schemas

* Improve InvocationParameter code maintainability

* Point TODO to github issues

* Fix tests and add todos

* Clean up types

* Don't import TypeAlias (deprecated)

* Remove invocationparametertype

* Update gql schema

* Ruff 🐶

* Update tests for new InvocationParameter spec

* Pin requirement for tests

* Fix urllib3 dependency

---------

Co-authored-by: Anthony Powell <apowell@arize.com>
  • Loading branch information
anticorrelator and cephalization authored Oct 31, 2024
1 parent 6330b20 commit 2e7e670
Show file tree
Hide file tree
Showing 18 changed files with 1,418 additions and 399 deletions.
123 changes: 114 additions & 9 deletions app/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,41 @@ enum AuthMethod {

union Bin = NominalBin | IntervalBin | MissingValueBin

type BooleanInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: Boolean
}

type BoundedFloatInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: Float
minValue: Float!
maxValue: Float!
}

enum CanonicalParameterName {
TEMPERATURE
MAX_COMPLETION_TOKENS
STOP_SEQUENCES
TOP_P
RANDOM_SEED
TOOL_CHOICE
}

input ChatCompletionInput {
messages: [ChatCompletionMessageInput!]!
model: GenerativeModelInput!
invocationParameters: InvocationParameters! = {}
invocationParameters: [InvocationParameterInput!]! = []
tools: [JSON!]
template: TemplateOptions
apiKey: String = null
Expand Down Expand Up @@ -837,6 +868,16 @@ type FinishedChatCompletion {
span: Span!
}

type FloatInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: Float
}

type FunctionCallChunk {
name: String!
arguments: String!
Expand Down Expand Up @@ -924,25 +965,67 @@ input InputCoordinate3D {
z: Float!
}

type IntInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: Int
}

type IntervalBin {
range: NumericRange!
}

input InvocationParameters {
temperature: Float
maxCompletionTokens: Int
maxTokens: Int
topP: Float
stop: [String!]
seed: Int
toolChoice: JSON
enum InvocationInputField {
value_int
value_float
value_bool
value_string
value_json
value_string_list
value_boolean
}

union InvocationParameter = IntInvocationParameter | FloatInvocationParameter | BoundedFloatInvocationParameter | StringInvocationParameter | JSONInvocationParameter | StringListInvocationParameter | BooleanInvocationParameter

interface InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
}

input InvocationParameterInput {
invocationName: String!
canonicalName: CanonicalParameterName = null
valueInt: Int
valueFloat: Float
valueBool: Boolean
valueString: String
valueJson: JSON
valueStringList: [String!]
valueBoolean: Boolean
}

"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf).
"""
scalar JSON @specifiedBy(url: "https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf")

type JSONInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: JSON
}

type LabelFraction {
label: String!
fraction: Float!
Expand Down Expand Up @@ -989,6 +1072,7 @@ type Model {

input ModelsInput {
providerKey: GenerativeProviderKey
modelName: String = null
}

type Mutation {
Expand Down Expand Up @@ -1185,6 +1269,7 @@ type PromptResponse {
type Query {
modelProviders: [GenerativeProvider!]!
models(input: ModelsInput = null): [GenerativeModel!]!
modelInvocationParameters(input: ModelsInput = null): [InvocationParameter!]!
users(first: Int = 50, last: Int, after: String, before: String): UserConnection!
userRoles: [UserRole!]!
userApiKeys: [UserApiKey!]!
Expand Down Expand Up @@ -1457,6 +1542,26 @@ enum SpanStatusCode {
UNSET
}

type StringInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: String
}

type StringListInvocationParameter implements InvocationParameterBase {
invocationName: String!
canonicalName: CanonicalParameterName
label: String!
required: Boolean!
hidden: Boolean!
invocationInputField: InvocationInputField!
defaultValue: [String!]
}

type Subscription {
chatCompletion(input: ChatCompletionInput!): ChatCompletionSubscriptionPayload!
}
Expand Down
Loading

0 comments on commit 2e7e670

Please sign in to comment.