Skip to content

Commit bca7025

Browse files
committed
added prompt by name check
1 parent 5f9d103 commit bca7025

4 files changed

Lines changed: 51 additions & 2 deletions

File tree

DotPrompt.Sql/DotPrompt.Sql.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<AssemblyName>DotPrompt.Sql</AssemblyName>
99
<Description>A SQL store for DotPrompt allowing you to store prompt files in a relational form</Description>
1010
<Authors>Richard Conway</Authors>
11-
<Version>0.2.1</Version>
12-
<PackageVersion>0.2.1</PackageVersion>
11+
<Version>0.2.2</Version>
12+
<PackageVersion>0.2.2</PackageVersion>
1313
<Company>Elastacloud</Company>
1414
<PackageProjectUrl>https://elastacloud.com</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/elastacloud/DotPrompt.Sql</RepositoryUrl>
@@ -46,5 +46,14 @@
4646
<None Remove="Resources\SqlQueries\AddSqlPrompt.sql" />
4747
<EmbeddedResource Include="Resources\SqlQueries\AddSqlPrompt.sql" />
4848
</ItemGroup>
49+
50+
<ItemGroup>
51+
<None Remove="Resources\SqlQueries\GetLatestPromptByName.sql" />
52+
<Resource Include="Resources\SqlQueries\GetLatestPromptByName.sql" />
53+
</ItemGroup>
54+
55+
<ItemGroup>
56+
<Folder Include="nupkgs\" />
57+
</ItemGroup>
4958

5059
</Project>

DotPrompt.Sql/IPromptRepository.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ public interface IPromptRepository
1616
/// </summary>
1717
/// <returns>An enumeration of prompts with different names</returns>
1818
IEnumerable<SqlPromptEntity> Load();
19+
/// <summary>
20+
/// This method will get the latest prompt given the name of the prompt. The exact name will nedd to be used.
21+
/// </summary>
22+
/// <param name="promptName">The name of the prompt - this is case sensitive.</param>
23+
/// <returns>A SqlPromptEntity or null</returns>
24+
Task<SqlPromptEntity?> GetLatestPromptByName(string promptName);
1925
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
WITH LatestPrompts AS (
2+
SELECT
3+
PromptId,
4+
PromptName,
5+
VersionNumber,
6+
CreatedAt,
7+
ModifiedAt,
8+
Model,
9+
OutputFormat,
10+
MaxTokens,
11+
SystemPrompt,
12+
UserPrompt,
13+
ROW_NUMBER() OVER (PARTITION BY PromptName ORDER BY VersionNumber DESC) AS RowNum
14+
FROM PromptFile
15+
)
16+
SELECT
17+
lp.PromptId,
18+
lp.PromptName,
19+
lp.VersionNumber,
20+
lp.CreatedAt,
21+
lp.ModifiedAt,
22+
lp.Model,
23+
lp.OutputFormat,
24+
lp.MaxTokens,
25+
lp.SystemPrompt,
26+
lp.UserPrompt
27+
FROM LatestPrompts lp
28+
WHERE lp.PromptName = @PromptName AND lp.RowNum = 1;

DotPrompt.Sql/SqlPromptRepository.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,10 @@ public IEnumerable<SqlPromptEntity> Load()
127127

128128
return promptDictionary.Values;
129129
}
130+
131+
/// <inheritdoc />
132+
public Task<SqlPromptEntity?> GetLatestPromptByName(string promptName)
133+
{
134+
throw new NotImplementedException();
135+
}
130136
}

0 commit comments

Comments
 (0)