Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khcheung/semantic-kernel-gradio
https://github.com/khcheung/semantic-kernel-gradio
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/khcheung/semantic-kernel-gradio
- Owner: khcheung
- License: mit
- Created: 2023-10-02T02:14:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-02T13:44:55.000Z (over 1 year ago)
- Last Synced: 2024-10-14T19:02:41.176Z (3 months ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-semantickernel - semantic-kernel-gradio - TextEmbeddingGeneration (Plugins)
README
# semantic-kernel-gradio
Using Gradio API for Semantic Kernel - TextEmbeddingGeneration
## Testing Embedding Service
Url: https://alexkhcheung-embeddingtest.hf.space/## Embedding Sevice (Python)
```python
import gradio as gr
from sentence_transformers import SentenceTransformer
import jsonmodel = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
def embedding(input):
embeddings = model.encode(input)
yield json.dumps(embeddings.tolist())with gr.Blocks() as iface:
with gr.Row():
inp = gr.Textbox(placeholder="Embedding Vector")
out = gr.Textbox()
btn = gr.Button("Run")
btn.click(fn=embedding, inputs=inp, outputs=out, api_name="embedding")iface.queue().launch()
```## Sample Use Gradio API for Embedding
```csharp
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AI.Embeddings;
using Simple.SemanticKernel.Connectors.Gradio;public class Program
{
public static async Task Main(string[] args)
{
var builder = new KernelBuilder();
builder.WithGradioEmbeddingGenerationService("https://alexkhcheung-embeddingtest.hf.space/", 0, setAsDefault: true);
var kernel = builder.Build();
var embeddingGeneration = kernel.GetService();
var embedding = await embeddingGeneration.GenerateEmbeddingsAsync(new List() { "Hello World !" });
Console.WriteLine(embedding[0]);
}
}
```