Skip to content

Chat demo App: How to fetch function arguments on the view? #99

@alelordelo

Description

@alelordelo

Is your feature request related to a problem? Please describe.
Would be great to be able to fetch function arguments on the view.

Describe the solution you'd like

When defined:

  let weatherFunction = ChatFunctionDeclaration(
            name: "getWeatherData",
            description: "Get the current weather in a given location",
            parameters: .init(
              type: .object,
              properties: [
                "location": .init(type: .string, description: "The city and state, e.g. San Francisco, CA"),
                "degrees": .init(type: .string, description: "The degrees, in celsius. Ex: 10c")

              ],
              required: ["location"]
            )
        )

When prompted "show me the weather in San Francisco"...

Current demo app shows the on the bubble: message.content
Would be great to be able to fetch the property, ex: function.degrees.

This would enable to place specific function properties on tables, graphs, etc...


 var body: some View {
        HStack {
            switch message.role {
            case .assistant:
                Text(message.content)
                    .padding(.horizontal, 16)
                    .padding(.vertical, 12)
                    .background(assistantBackgroundColor)
                    .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
                Spacer(minLength: 24)
            case .user:
                Spacer(minLength: 24)
                Text(message.content)
                    .padding(.horizontal, 16)
                    .padding(.vertical, 12)
                    .foregroundColor(userForegroundColor)
                    .background(userBackgroundColor)
                    .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
            case .function:
              Text(message.content)
                  .font(.footnote.monospaced())
                  .padding(.horizontal, 16)
                  .padding(.vertical, 12)
                  .background(funcBackgroundColor)
                  .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
              Spacer(minLength: 24)
            case .system:
                EmptyView()
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions