Skip to content

Instantly share code, notes, and snippets.

View YanSte's full-sized avatar
🌎
Working from Zurich

Yannick Stephan YanSte

🌎
Working from Zurich
View GitHub Profile
@YanSte
YanSte / Langchain FastAPI and Stream Response.py
Created April 19, 2024 11:02
Langchain FastAPI and Stream Response
# Fast API
```
@router.get("/myExample")
async def mySpecialAPI(
session_id: UUID,
input="Hello",
) -> StreamResponse:
# Note: Don't write await we need a coroutine
invoke = chain.ainvoke(..)
@YanSte
YanSte / semi_structured_rag_v1.ipynb
Created February 10, 2024 08:21 — forked from esenthil2018/semi_structured_rag_v1.ipynb
Semi_Structured_RAG_V1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@YanSte
YanSte / agent.py
Created January 1, 2024 11:07 — forked from wiseman/agent.py
Langchain example: self-debugging
from io import StringIO
import sys
from typing import Dict, Optional
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents.tools import Tool
from langchain.llms import OpenAI
@YanSte
YanSte / agent.py
Created January 1, 2024 11:07 — forked from wiseman/agent.py
Langchain example: self-debugging
from io import StringIO
import sys
from typing import Dict, Optional
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents.tools import Tool
from langchain.llms import OpenAI
@YanSte
YanSte / ResultSuccessExtensions.swift
Created August 18, 2022 08:36
Result, a success, storing a Success value.
public extension Result where Success == Void {
/// A success, storing a Success value.
///
/// Instead of `.success(())`, now `.success`
static var success: Result {
return .success(())
}
}
@YanSte
YanSte / UserDefaultsStore.swift
Created August 18, 2022 07:59
UserDefaultsStore, Generic UserDefaults Wrapper Using Property Wrapper
import Foundation
/// UserDefaultsStore, a generic UserDefaults Wrapper store
///
/// How to use:
/// ```
/// enum MyEnum {
/// case myKey
/// }
/// @UserDefaultsStore(
@YanSte
YanSte / Describable.swift
Last active August 18, 2022 08:02
Describable, Descriptible de classe, struct etc..
import Foundation
// MARK: - Describable
public protocol Describable {
var typeName: String { get }
static var typeName: String { get }
}
// MARK: - Describable extensions
@YanSte
YanSte / Vibrations.swift
Last active August 18, 2022 08:02
Vibrations, notification feedback type
import AVFoundation
import UIKit
// MARK: - Vibrations
public enum Vibrations {
/// A notification feedback type, indicating that a task has failed.
case error
/// A notification feedback type, indicating that a task has completed successfully.
@YanSte
YanSte / Predicate.swift
Last active August 18, 2022 08:02
Predicate, A definition of logical conditions for constraining a search for a fetch or for in-memory filtering
import Foundation
/// A definition of logical conditions for constraining a search for a fetch or for in-memory filtering.
/// More info [here](https://www.swiftbysundell.com/articles/predicates-in-swift/)
///
/// Sample:
///
/// func myMethod(predicate: Predicate<MyObject>) -> Bool {
/// objects.contains { predicate(obj) }
/// }
@YanSte
YanSte / UIWrapping.swift
Last active August 18, 2022 08:01
UIWrapping, Wrapping UIKit to SwiftUI
import SwiftUI
/// Provides a convenient 'wrapper' around a UIView
public struct UIWrapping<V>: View {
let wrapped: AnyView
public var body: some View { wrapped }
// MARK: Initializers
/// Instantiates a wrapper for a `UIView`