Skip to content

Commit 826c048

Browse files
Add basic specification (#1)
1 parent cb91e52 commit 826c048

24 files changed

+610
-26
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// The mapping between an AuthField and the field name in the authentication request.
5+
/// </summary>
6+
/// <param name="AuthField">The AuthField that is mapped to the field name.</param>
7+
/// <param name="FieldName">The field name in the authentication request.</param>
8+
public record AuthFieldMapping(
9+
AuthField AuthField,
10+
string FieldName);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// The response to an authentication request.
5+
/// </summary>
6+
/// <param name="Success">True, when the authentication was successful.</param>
7+
/// <param name="Token">The token to use for further requests.</param>
8+
/// <param name="Message">When the authentication was not successful, this contains the reason.</param>
9+
public readonly record struct AuthResponse(
10+
bool Success,
11+
string? Token,
12+
string? Message);

DemoServer/DataModel/AuthScheme.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// Describes one authentication scheme for this data source.
5+
/// </summary>
6+
/// <param name="AuthMethod">The method used for authentication, e.g., "API Key," "Username/Password," etc.</param>
7+
/// <param name="AuthFieldMappings">A list of field mappings for the authentication method. The client must know,
8+
/// e.g., how the password field is named in the request.</param>
9+
public readonly record struct AuthScheme(
10+
AuthMethod AuthMethod,
11+
List<AuthFieldMapping> AuthFieldMappings);

DemoServer/DataModel/ChatThread.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// A chat thread, which is a list of content blocks.
5+
/// </summary>
6+
/// <param name="ContentBlocks">The content blocks in this chat thread.</param>
7+
public readonly record struct ChatThread(List<ContentBlock> ContentBlocks);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// A block of content of a chat thread.
5+
/// </summary>
6+
/// <remarks>
7+
/// Images and other media are base64 encoded.
8+
/// </remarks>
9+
/// <param name="Content">The content of the block. Remember that images and other media are base64 encoded.</param>
10+
/// <param name="Role">The role of the content in the chat thread.</param>
11+
/// <param name="Type">The type of the content, e.g., text, image, video, etc.</param>
12+
public readonly record struct ContentBlock(
13+
string Content,
14+
Role Role,
15+
ContentType Type);

DemoServer/DataModel/Context.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// Matching context returned by the data source as a result of a retrieval request.
5+
/// </summary>
6+
/// <param name="Name">The name of the source, e.g., a document name, database name,
7+
/// collection name, etc.</param>
8+
/// <param name="Category">What are the contents of the source? For example, is it a
9+
/// dictionary, a book chapter, business concept, a paper, etc.</param>
10+
/// <param name="Path">The path to the content, e.g., a URL, a file path, a path in a
11+
/// graph database, etc.</param>
12+
/// <param name="Type">The type of the content, e.g., text, image, video, audio, speech, etc.</param>
13+
/// <param name="MatchedContent">The content that matched the user prompt. For text, you
14+
/// return the matched text and, e.g., three words before and after it.</param>
15+
/// <param name="SurroundingContent">The surrounding content of the matched content.
16+
/// For text, you may return, e.g., one sentence or paragraph before and after
17+
/// the matched content.</param>
18+
/// <param name="Links">Links to related content, e.g., links to Wikipedia articles,
19+
/// links to sources, etc.</param>
20+
public readonly record struct Context(
21+
string Name,
22+
string Category,
23+
string? Path,
24+
ContentType Type,
25+
string MatchedContent,
26+
string[] SurroundingContent,
27+
string[] Links);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// Information about the data source.
5+
/// </summary>
6+
/// <param name="Name">The name of the data source, e.g., "Internal Organization Documents."</param>
7+
/// <param name="Description">A short description of the data source. What kind of data does it contain?
8+
/// What is the data source used for?</param>
9+
public readonly record struct DataSourceInfo(
10+
string Name,
11+
string Description);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// Represents information about the used embedding for this data source. The purpose of this information is to give the
5+
/// interested user an idea of what kind of embedding is used and what it does.
6+
/// </summary>
7+
/// <param name="EmbeddingType">What kind of embedding is used. For example, "Transformer Embedding," "Contextual Word
8+
/// Embedding," "Graph Embedding," etc.</param>
9+
/// <param name="EmbeddingName">Name the embedding used. This can be a library, a framework, or the name of the used
10+
/// algorithm.</param>
11+
/// <param name="Description">A short description of the embedding. Describe what the embedding is doing.</param>
12+
/// <param name="UsedWhen">Describe when the embedding is used. For example, when the user prompt contains certain
13+
/// keywords, or anytime?</param>
14+
/// <param name="Link">A link to the embedding's documentation or the source code. Might be null.</param>
15+
public readonly record struct EmbeddingInfo(
16+
string EmbeddingType,
17+
string EmbeddingName,
18+
string Description,
19+
string UsedWhen,
20+
string? Link);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// Information about a retrieval process, which this data source implements.
5+
/// </summary>
6+
/// <param name="Id">A unique identifier for the retrieval process. This can be a GUID, a unique name, or an increasing integer.</param>
7+
/// <param name="Name">The name of the retrieval process, e.g., "Keyword-Based Wikipedia Article Retrieval".</param>
8+
/// <param name="Description">A short description of the retrieval process. What kind of retrieval process is it?</param>
9+
/// <param name="Link">A link to the retrieval process's documentation, paper, Wikipedia article, or the source code. Might be null.</param>
10+
/// <param name="ParametersDescription">A dictionary that describes the parameters of the retrieval process. The key is the parameter name,
11+
/// and the value is a description of the parameter. Although each parameter will be sent as a string, the description should indicate the
12+
/// expected type and range, e.g., 0.0 to 1.0 for a float parameter.</param>
13+
/// <param name="Embeddings">A list of embeddings used in this retrieval process. It might be empty in case no embedding is used.</param>
14+
public readonly record struct RetrievalInfo(
15+
string Id,
16+
string Name,
17+
string Description,
18+
string? Link,
19+
Dictionary<string, string>? ParametersDescription,
20+
List<EmbeddingInfo> Embeddings);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace DemoServer.DataModel;
2+
3+
/// <summary>
4+
/// The retrieval request sent by AI Studio.
5+
/// </summary>
6+
/// <remarks>
7+
/// Images and other media are base64 encoded.
8+
/// </remarks>
9+
/// <param name="LatestUserPrompt">The latest user prompt that AI Studio received.</param>
10+
/// <param name="LatestUserPromptType">The type of the latest user prompt, e.g., text, image, etc.</param>
11+
/// <param name="Thread">The chat thread that the user is currently in.</param>
12+
/// <param name="RetrievalProcessId">Optional. The ID of the retrieval process that the data source should use.
13+
/// When null, the data source chooses an appropriate retrieval process. Selecting a retrieval process is optional
14+
/// for AI Studio users. Most users do not specify a retrieval process.</param>
15+
/// <param name="Parameters">A dictionary of parameters that the data source should use for the retrieval process.
16+
/// Although each parameter will be sent as a string, the retrieval process specifies the expected type and range.</param>
17+
/// <param name="MaxMatches">The maximum number of matches that the data source should return. AI Studio uses
18+
/// any value below 1 to indicate that the data source should return as many matches as appropriate.</param>
19+
public readonly record struct RetrievalRequest(
20+
string LatestUserPrompt,
21+
ContentType LatestUserPromptType,
22+
ChatThread Thread,
23+
string? RetrievalProcessId,
24+
Dictionary<string, string>? Parameters,
25+
int MaxMatches);

0 commit comments

Comments
 (0)