-
Notifications
You must be signed in to change notification settings - Fork 875
Expand file tree
/
Copy pathAppHost.cs
More file actions
79 lines (69 loc) · 2.4 KB
/
Copy pathAppHost.cs
File metadata and controls
79 lines (69 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var builder = DistributedApplication.CreateBuilder(args);
#if (IsOllama) // ASPIRE PARAMETERS
#elif (IsOpenAI)
// You will need to set the connection string to your own value
// You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line:
// cd this-project-directory
// dotnet user-secrets set ConnectionStrings:openai "Key=YOUR-API-KEY"
var openai = builder.AddConnectionString("openai");
#else // IsAzureOpenAI
// See https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration
// for instructions providing configuration values
var openai = builder.AddAzureOpenAI("openai");
openai.AddDeployment(
name: "gpt-4o-mini",
modelName: "gpt-4o-mini",
modelVersion: "2024-07-18");
openai.AddDeployment(
name: "text-embedding-3-small",
modelName: "text-embedding-3-small",
modelVersion: "1");
#endif
#if (IsAzureAISearch)
// See https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration
// for instructions providing configuration values
var search = builder.AddAzureSearch("search");
#endif
#if (IsOllama) // AI SERVICE PROVIDER CONFIGURATION
var ollama = builder.AddOllama("ollama")
.WithDataVolume();
var chat = ollama.AddModel("chat", "llama3.2");
var embeddings = ollama.AddModel("embeddings", "all-minilm");
#endif
#if (IsAzureAISearch) // VECTOR DATABASE CONFIGURATION
#elif (IsQdrant)
var vectorDB = builder.AddQdrant("vectordb")
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);
#else // IsLocalVectorStore
#endif
var markitdown = builder.AddContainer("markitdown", "mcp/markitdown")
.WithArgs("--http", "--host", "0.0.0.0", "--port", "3001")
.WithHttpEndpoint(targetPort: 3001, name: "http");
var webApp = builder.AddProject<Projects.AIChatWeb_CSharp_Web_AspireClassName_Web>("aichatweb-app");
#if (IsOllama) // AI SERVICE PROVIDER REFERENCES
webApp
.WithReference(chat)
.WithReference(embeddings)
.WaitFor(chat)
.WaitFor(embeddings);
#elif (IsOpenAI)
webApp.WithReference(openai);
#else // IsAzureOpenAI
webApp
.WithReference(openai)
.WaitFor(openai);
#endif
#if (IsAzureAISearch) // VECTOR DATABASE REFERENCES
webApp
.WithReference(search)
.WaitFor(search);
#elif (IsQdrant)
webApp
.WithReference(vectorDB)
.WaitFor(vectorDB);
#else // IsLocalVectorStore
#endif
webApp
.WithEnvironment("MARKITDOWN_MCP_URL", markitdown.GetEndpoint("http"));
builder.Build().Run();