microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ecec6489db2ad85ccd1be99c0860dc3b057af2b1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

python/fineTuning/unsloth/knowledgePrompt.py

6lines · modecode

1# Copyright (c) Microsoft Corporation and Henry Lucco.
2# Licensed under the MIT License.
3
4def get_knowledge_prompt(message: str) -> str:
5 template = "You are a service that translates user messages in a conversation into JSON objects of type \"KnowledgeResponse\" according to the following TypeScript definitions:\n```\n\n\nexport type Quantity = {\n amount: number;\n units: string;\n};\nexport type Value = string | number | boolean | Quantity;\nexport type Facet = {\n name: string;\n // Very concise values.\n value: Value;\n};\n// Specific, tangible people, places, institutions or things only\nexport type ConcreteEntity = {\n // the name of the entity or thing such as \"Bach\", \"Great Gatsby\", \"frog\" or \"piano\"\n name: string;\n // the types of the entity such as \"speaker\", \"person\", \"artist\", \"animal\", \"object\", \"instrument\", \"school\", \"room\", \"museum\", \"food\" etc.\n // An entity can have multiple types; entity types should be single words\n type: string[];\n // A specific, inherent, defining, or non-immediate facet of the entity such as \"blue\", \"old\", \"famous\", \"sister\", \"aunt_of\", \"weight: 4 kg\"\n // trivial actions or state changes are not facets\n // facets are concise \"properties\"\n facets?: Facet[];\n};\nexport type ActionParam = {\n name: string;\n value: Value;\n};\nexport type VerbTense = \"past\" | \"present\" | \"future\";\nexport type Action = {\n // Each verb is typically a word\n verbs: string[];\n verbTense: VerbTense;\n subject: string;\n object?: string;\n indirectObject?: string;\n params?: (string | ActionParam)[];\n // If the action implies this additional facet or property of the subject, such as hobbies, activities, interests, personality\n subjectFacet?: Facet | undefined;\n};\n// Detailed and comprehensive knowledge response\nexport type KnowledgeResponse = {\n entities: ConcreteEntity[];\n // The 'subject' and 'object' must correspond to the 'name' of an entity listed in the 'entities' array.\n actions: Action[];\n\n```\nThe following are messages in a conversation:\n\"\"\"\n<<message>>\n\"\"\"\nThe following is the user request translated into a JSON object with no spaces and no properties with the value undefined:\n"
6 return template.replace("<<message>>", message)
7