File tree Expand file tree Collapse file tree
DifySharp.Test/Apis/KnowledgeBaseApiTest Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333 var response = await api . PostCreateDocumentByTextAsync (
3434 "<your-dataset-id>" , // add a dataset id here
3535 new CreateByText . RequestBody (
36- $ "Test Document { uuid } ",
37- "Test Content" ,
38- IndexingTechnique . Economy ,
39- DocForm . TextModel ,
40- "" ,
41- new ProcessRule (
36+ Name : $ "Test Document { uuid } ",
37+ Text : "Test Content" ,
38+ DocType : null ,
39+ DocMetadata : null ,
40+ IndexingTechnique : IndexingTechnique . Economy ,
41+ DocForm : DocForm . TextModel ,
42+ DocLanguage : "" ,
43+ ProcessRule : new ProcessRule (
4244 "automatic" ,
4345 new Rules (
4446 [
6365 )
6466 )
6567 ) ,
66- new CreateByText . RetrievalModel (
68+ RetrievalModel : new CreateByText . RetrievalModel (
6769 CreateByText . SearchMethod . HybridSearch ,
6870 false ,
6971 new CreateByText . RerankingModel (
7476 false ,
7577 0.9f
7678 ) ,
77- "" ,
78- ""
79+ EmbeddingModel : "" ,
80+ EmbeddingModelProvider : ""
7981 ) ) ;
8082
8183 var document = response . Document ;
Original file line number Diff line number Diff line change @@ -34,12 +34,14 @@ public ChunkApiTestFixture()
3434
3535 // crate a document
3636 var createDocRequestBody = new CreateByText . RequestBody (
37- $ "Chunk Api Test Document { uuid } ",
38- "Test Content \n \n Test Content \n \n Test Content" ,
39- IndexingTechnique . Economy ,
40- DocForm . TextModel ,
41- "" ,
42- new ProcessRule (
37+ Name : $ "Chunk Api Test Document { uuid } ",
38+ Text : "Test Content \n \n Test Content \n \n Test Content" ,
39+ DocType : null ,
40+ DocMetadata : null ,
41+ IndexingTechnique : IndexingTechnique . Economy ,
42+ DocForm : DocForm . TextModel ,
43+ DocLanguage : "" ,
44+ ProcessRule : new ProcessRule (
4345 "automatic" ,
4446 new Rules (
4547 [
@@ -64,7 +66,7 @@ public ChunkApiTestFixture()
6466 )
6567 )
6668 ) ,
67- new CreateByText . RetrievalModel (
69+ RetrievalModel : new CreateByText . RetrievalModel (
6870 CreateByText . SearchMethod . HybridSearch ,
6971 false ,
7072 new CreateByText . RerankingModel (
@@ -75,8 +77,8 @@ public ChunkApiTestFixture()
7577 false ,
7678 0.9f
7779 ) ,
78- "" ,
79- ""
80+ EmbeddingModel : "" ,
81+ EmbeddingModelProvider : ""
8082 ) ;
8183
8284 Document = Client . PostCreateDocumentByTextAsync (
Original file line number Diff line number Diff line change @@ -93,15 +93,17 @@ public async Task TestCreateDocumentByText_ShouldHaveDocumentInfoInResponse()
9393 var response = await Client . PostCreateDocumentByTextAsync (
9494 Dataset . Id ,
9595 new CreateByText . RequestBody (
96- $ "Test Document { uuid } ",
97- "Test Content" ,
98- IndexingTechnique . Economy ,
99- DocForm . TextModel ,
100- "" ,
101- _defaultProcessRule ,
102- _defaultRetrievalModel ,
103- "" ,
104- ""
96+ Name : $ "Test Document { uuid } ",
97+ Text : "Test Content" ,
98+ DocType : null ,
99+ DocMetadata : null ,
100+ IndexingTechnique : IndexingTechnique . Economy ,
101+ DocForm : DocForm . TextModel ,
102+ DocLanguage : "" ,
103+ ProcessRule : _defaultProcessRule ,
104+ RetrievalModel : _defaultRetrievalModel ,
105+ EmbeddingModel : "" ,
106+ EmbeddingModelProvider : ""
105107 ) ) ;
106108
107109
@@ -156,7 +158,7 @@ public async Task TestDeleteDocument_ShouldNotContainsDocumentInDataset()
156158 foreach ( var doc in Documents )
157159 {
158160 var response = await Client . DeleteDocument ( Dataset . Id , doc . Id ) ;
159- Assert . Equal ( "success" , response . Result ) ;
161+ Assert . True ( response . IsSuccessStatusCode ) ;
160162 }
161163
162164 var documents = await Client . GetDocuments ( Dataset . Id ) ;
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ int batch
132132 /// <param name="documentId"></param>
133133 /// <returns></returns>
134134 [ HttpDelete ( "/v1/datasets/{datasetId}/documents/{documentId}" ) ]
135- public Task < Delete . ResponseBody > DeleteDocument (
135+ public Task < HttpResponseMessage > DeleteDocument (
136136 string datasetId ,
137137 string documentId
138138 ) ;
@@ -191,9 +191,9 @@ string documentId
191191 /// <param name="datasetId">The unique identifier for the dataset.</param>
192192 /// <param name="documentId">The unique identifier for the document within the dataset.</param>
193193 /// <param name="segmentId">The unique identifier for the segment to be deleted.</param>
194- /// <returns>A task that represents the asynchronous operation. The task result contains the response body of the delete operation .</returns>
194+ /// <returns>A task that represents the asynchronous operation. The task result contains the HTTP response message .</returns>
195195 [ HttpDelete ( "/v1/datasets/{datasetId}/documents/{documentId}/segments/{segmentId}" ) ]
196- public Task < Delete . ResponseBody > DeleteSegments (
196+ public Task < HttpResponseMessage > DeleteSegments (
197197 string datasetId ,
198198 string documentId ,
199199 string segmentId
Original file line number Diff line number Diff line change 1- namespace DifySharp . KnowledgeBase . Chunk ;
1+ using System . Text . Json . Serialization ;
2+
3+ namespace DifySharp . KnowledgeBase . Chunk ;
24
35/// <summary>
46/// Delete a chunk in document
57/// </summary>
68public record Delete
79{
8- public record ResponseBody ( string Result ) ;
10+ public class ResponseBody
11+ {
12+ [ JsonPropertyName ( "result" ) ]
13+ public string ? Result { get ; set ; } = "success" ;
14+ }
915}
Original file line number Diff line number Diff line change 1- namespace DifySharp . KnowledgeBase ;
1+ using System . Text . Json . Serialization ;
2+
3+ namespace DifySharp . KnowledgeBase ;
24
35/// <summary>
46/// Format of indexed content
@@ -8,15 +10,18 @@ public enum DocForm
810 /// <summary>
911 /// Text documents are directly embedded; <see cref="IndexingTechnique.Economy"/> mode defaults to using this form
1012 /// </summary>
13+ [ JsonPropertyName ( "text_model" ) ]
1114 TextModel ,
1215
1316 /// <summary>
1417 /// Parent-child mode
1518 /// </summary>
19+ [ JsonPropertyName ( "hierarchical_model" ) ]
1620 HierarchicalModel ,
1721
1822 /// <summary>
1923 /// Q and A Mode: Generates Q and A pairs for segmented documents and then embeds the questions
2024 /// </summary>
25+ [ JsonPropertyName ( "qa_model" ) ]
2126 QaModel ,
2227}
You can’t perform that action at this time.
0 commit comments