This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.post("/agent/execute") | |
async def execute_agent(request: AgentRequest): | |
# Framework-independent logic | |
return await process_agent_request(request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BundleConfig.cs (for older versions) | |
// Use third-party libraries like WebOptimizer for .NET Core | |
public static void RegisterBundles(BundleCollection bundles) | |
{ | |
bundles.Add(new ScriptBundle("~/bundles/main").Include( | |
"~/wwwroot/js/*.js")); | |
bundles.Add(new StyleBundle("~/Content/css").Include( | |
"~/wwwroot/css/*.css")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Service Example | |
public class ProductService | |
{ | |
private readonly IMemoryCache _cache; | |
private readonly DataContext _context; | |
public ProductService(IMemoryCache cache, DataContext context) | |
{ | |
_cache = cache; | |
_context = context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="image.jpg" loading="lazy" alt="Description"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Startup.cs | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddResponseCompression(options => | |
{ | |
options.MimeTypes = new[] { "image/jpeg", "image/png", "image/gif" }; | |
}); | |
} | |
public void Configure(IApplicationBuilder app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- View Example --> | |
<a href="/products/details/1" onmouseover="prefetch('/products/details/1')">Product Details</a> | |
<script> | |
function prefetch(url) { | |
fetch(url, { method: 'GET', headers: { 'X-Prefetch': 'true' } }); | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Controller Example | |
public class HomeController : Controller | |
{ | |
public IActionResult Index() | |
{ | |
// Fetch data required for the view | |
var model = GetData(); | |
return View(model); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<string>> SemanticSearch(string query, List<string> documents) | |
{ | |
// This is a simplified example. In practice, you would use an AI service that provides semantic search. | |
var embeddings = await GetEmbeddings(query); | |
// Compare embeddings with document embeddings to find the most relevant documents | |
// Return a list of matched documents | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<string> TranslateText(string text, string targetLanguage) | |
{ | |
var requestBody = new | |
{ | |
q = text, | |
target = targetLanguage, | |
format = "text" | |
}; | |
var httpContent = new StringContent(JsonConvert.SerializeObject(requestBody), System.Text.Encoding.UTF8, "application/json"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
public class ChatGPTService | |
{ | |
private readonly string apiKey = "YOUR_OPENAI_API_KEY"; | |
private readonly HttpClient client; |
NewerOlder