This file contains 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
# The goal of this file is to provide a FastAPI application for handling | |
# chat requests amd generation AI-powered responses using conversation chains. | |
# The application uses the LangChaing library, which includes a chatOpenAI model | |
# for natural language processing. | |
# The `StreamingConversationChain` class is responsible for creating and storing | |
# conversation memories and generating responses. It utilizes the `ChatOpenAI` model | |
# and a callback handler to stream responses as they're generated. | |
# The application defines a `ChatRequest` model for handling chat requests, |
This file contains 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
#lang racket | |
;; Adapted from Figure 9 of Flanagan et al. | |
(define (normalize-term M) | |
(normalize M (lambda (x) x))) | |
(define (normalize M k) | |
(match M | |
[`(lambda ,args ,body) | |
(k `(lambda ,args ,(normalize-term body)))] |
This file contains 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
#lang racket | |
(require cpsc411/compiler-lib) | |
(module+ a | |
;; Compiler style | |
(define (expand e) | |
(define (expand-expr e) | |
(match e | |
[`(and ,e1 ,e2) |
This file contains 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
#lang racket/base | |
; Lock-free FIFO queues, loosely based on “Simple, Fast, and Practical | |
; Non-Blocking and Blocking Concurrent Queue Algorithms”. | |
(require racket/contract | |
racket/future | |
(only-in racket/unsafe/ops unsafe-struct*-cas!)) | |
(provide queue? |
This file contains 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
;; A tetris game -- partial implementation, part 5 | |
;; Copyright (c) 2020 Alex Harsányi (AlexHarsanyi@gmail.com) | |
;; Permission is hereby granted, free of charge, to any person obtaining a | |
;; copy of this software and associated documentation files (the "Software"), | |
;; to deal in the Software without restriction, including without limitation | |
;; the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
;; and/or sell copies of the Software, and to permit persons to whom the | |
;; Software is furnished to do so, subject to the following conditions: |
This file contains 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
#lang rosette/safe | |
(require rosette/lib/angelic | |
rosette/lib/match) | |
(current-bitwidth #f) | |
(require (only-in racket list*)) | |
; bit operations | |
(define (rotate-right i x) |
This file contains 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
#lang racket/base | |
(require redex) | |
(define-language μ-Kanren | |
;; Syntax | |
[#|Term |# t ::= x () number (t t)] | |
[#|Goal |# g ::= (g ∨ g) (g ∧ g) (∃ (x ...) g) (↓ f t ...) (t ≡ t)] | |
[#|Goal Abs|# f ::= (side-condition (name f any) (procedure? (term f)))] | |
[#|Variable|# x ::= variable-not-otherwise-mentioned] |
This file contains 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
from django.utils.text import gettext_lazy as _ | |
from rest_framework import serializers | |
from rest_framework_simplejwt.tokens import RefreshToken, TokenError | |
class RefreshTokenSerializer(serializers.Serializer): | |
refresh = serializers.CharField() | |
default_error_messages = { | |
'bad_token': _('Token is invalid or expired') | |
} |
This file contains 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
#lang s-exp "typecheck-lang.rkt" | |
(define [! : (-> Integer Integer)] | |
(lambda ([x : Integer]) (if (= x 0) 1 (* x (! (- x 1)))))) | |
(! 6) | |
(provide !) |
This file contains 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
-- A simply-typed lambda calculus, and a definition of normalisation by | |
-- evaluation for it. | |
-- | |
-- The NBE implementation is based on a presentation by Sam Lindley from 2016: | |
-- http://homepages.inf.ed.ac.uk/slindley/nbe/nbe-cambridge2016.pdf | |
-- | |
-- Adapted to handle terms with explicitly typed contexts (Sam's slides only | |
-- consider open terms with the environments left implicit/untyped). This was a | |
-- pain in the ass to figure out. |
NewerOlder